I just bought template .Now i want to convert this HTML pages into a .aspx page with .cs with it.Does any one have any way to get through this !?but also keeping the java scripts in the html as it is .Thx!
Create new .aspx page and copy the code from html file. If it contains any javascripts added that as a seperate file and link it
An html file won't have any code in it, so just change the extension to .aspx.
You can then manually add a .cs file, and update the controls to be asp controls as necessary.
Your best bet would be to just create a new page in Visual Studio, and then copy the html over. At some point your going to need to create a Web Site or Web Application depending on your needs, and that will take care of creating the correct <% Page %> declaration and code-behind. You'll likely want to put that template into a Master page really.
Related
I am confused, how would I be able to link an ASPX file in Visual Studio from a different folder within the solution? So I have the Solution for my web ASPX site, and I have another folder that contains all of my html/css/javascript/images. How would I communicate between the two and have an HTML page link to the ASPX site?
I know the code should be: View Reports right?
You as a genreal rule need/want/should/will palce those aspx pages in your current project folder. The reason of course is that "folder" becomes the root folder of the web site when you publish.
so, if you have some other aspx pages that you want to use? then from vs choose add->existing item, and then you can browse to that aspx page. This is really a SIMPLE IMPORT of that page into the current project.
So, the web pages and folders MUST exist in your current project, and you are NOT free to reference or use or have aspx pages outside of your current project. The web site layout will not work correclty.
Now, you can ceratinly refernce other projects "code" and things like other libraries of code. But a aspx web page is going to be converted to standard HTML for a browser, and those aspx pages will become the url of the web site, and thus all such pages must be in the root of the project, or in sub folders of that root project.
So, you might have:
Welcome.aspx
but, you can say add a new folder to this project, and maybe call it
SiteAdmin
So, now, you can place aspx pages in that folder, and your URL will become:
http:mycoolebsite/SiteAdmin/Manage.aspx
so, yes, all aspx pages have to be part of the starting folder for the web site.
it not at all clear what you mean by "link".
I mean, one can have page1.aspx, and then page2.aspx.
you can the drop a button in page 1, and when you click on it, it jumps to page2. This would not really be called "linking", but navagation to another page.
You can thus of course add a hyper-link in page one. or you can drop in a button, and with some code jump/navigate to that page2.aspx.
So, assuming I have page1.aspx, and page2.aspx, then you are free to drop in a button, say like this:
<asp:Button ID="Button1" runat="server" Text="Jump to page2.aspx"
OnClick="Button1_Click" />
And code behind could be this:
Protected Sub Button1_Click(sender As Object, e As EventArgs)
Response.Redirect("~/page2.aspx")
End Sub
But, you don't have to use code behind, and you can say drop in a hyperlink control, and do this without code.
eg:
<asp:HyperLink ID="HyperLink1" runat="server"
NavigateUrl="~/About.aspx">HyperLink</asp:HyperLink>
So, you can jump/navagate from a html page to a aspx page by using a hyperlink.
If this is a html page, then use a html control, not a asp.net one, and thus use:
About our site
So, you can use a plain jane hyper link, and use one in a aspx page, or a html page
Hello everyone quick question.
First time working with java script
I have a jsp file that will create a data grid and one of the columns of the data grid are checkboxes. My question is can a JSP file contain javascript in it or will I have to create a different file for just the javascript. The function of the java script will be a select all button.
If JSP can hold javascript where does the code belong? by this I mean what headers does the code reside int?
<html>
Thanks for the help everyone.
I've just answered a similar question here:
https://stackoverflow.com/questions/25059168/java-websocket-client-in-jsp-possible/25059382#25059382
The generic answer is: JSP can contain anything that a regular HTML page can contain. JSP is an HTML extended with JSP tags that are processed on a server. After the JSP tags are processed and a response is generated there is no any difference between that response and a regular HTML.
So, the question really is where to store the java scripts in an HTML. I think, the cleanest way would be to put them to a separate file or files and then use a <script> tag with an 'src' attribute:
<script src="<java-script-url>"></script>
But in cases when java scripts are not that big and complicated, it's OK to include them to the page itself under <head> element of your page.
Script tags should be added under the head tag of the HTML node.
The script tag can then simply contain JavaScript.
This should not be any different from adding a script tag to a normal html page.
<html>
<head>
<script type="text/javascript"><!-- required for FF3 and Opera --><jsp:text> </jsp:text></script>
</head>
</html>
Add inline javascript to the body of the jsp:text (jsp:text may not be necessary, I am not sure), or add a src="" attribute containing the path relative (or absolute) to the URL the browser will consume the page from.
Yes, it technically can. You'd simply put it under a <script> tag inside <head>. However, I recommend including a JavaScript file using a <script> tag, instead of inserting JavaScript directly into your JSP.
There is no dependency between JavaScript and JSP because JavaScript is used for client side scripting and JSP is used to produce HTML pages or contents dynamically using Java EE. JavaScript can be used along with HTML on any browser that supports JavaScript (all browsers we use for work and development supports JavaScript).
Feel free to write JavaScript functions and code for HTML page to create an interactive website, it doesn't matter whether you are using ASP, JSP or PHP for server side scripting and dynamic HTML content generation because all these frameworks produce and use HTML, CSS, JavaScript and Media Contents. Your browser can only understand HTML, CSS and JavaScript, its the web server application which understands JSP and its Java code.
Why don't you write this code in your JSP page and check yourself whether it works or not.
<script type="text/javascript">alert('Hello World!');</script>
JavaScript is not limited to be written inside <head> tag, you can write it anywhere you want in a HTML page. There are some cases in which you would like to write a JavaScript function at the end of <body> tag.
Hope someone can help me on this. I manage an ASP.Net website and usually update script files and css files very often. I add current time appended into a single string as a query string parameter (eg: profileImage.jpg?123021) which makes the browser to look for the file without getting it from cache.
How can I do the same thing to all script tags and css links from the server side so that it loads the latest version of the file.
Any help appreciated.
Amila
If your asp.net website uses Master Pages, it should be easy to make these changes in the Master Page file. Look a file with the extension .master. If you are not sure how to make the specific edit, post the <head> area from the master page markup in a new question.
MSDN Master Pages: http://msdn.microsoft.com/en-us/library/wtxbf3hh(v=vs.100).aspx
If your site does not use master pages, then you'd need to create some server-side logic that affects the <head> section of the page. Below are some links to related QA's about injecting script and styles from the server side.
ASP.NET: How to (programmatically) attach a <script> tag, containing a link to .js, to <head>?
How to Add script codes before the </body> tag ASP.NET
in view, i have at the bottom many javascript and jquery code, and i dont like it, so im placing all scripts into one ascx file, and make partial rendering like:
<!--<%Html.RenderPartial("~/Views/Home/StationLogics.ascx"); %>-->
of this ascx file with scripts. So, is there any better way?
cant place it to master page, cause not always i need this scripts, if user get some privilage, he can use some scripts, if not - others
it mat not be what u intended to know but i think that u can place all ur javascript and jquery code in a js file like in yourjavascript.js file and place a reference of js file in your view or the master page page file that the view is inheriting e.g.
<script src="<%=ResolveUrl("~/scripts/yourjavascript.js") %>" type="text/javascript"></script>
You could add your common JavaScript files in the head element of a Master page, and then let your pages reference that master page using the <%# Page %> directive, for example:
<%# Page MasterPageFile="/Views/Shared/Site.Master" %>
Now, all you have to do is update the scripts in your master page, and pages referencing that master page will have the scripts as well.
However, if your scripts are too specific to include in the master page, then your solution is probably fine.
I am trying to set up a masterpage that contains a javascript popup subroutine that can be used in multiple web pages. The popup already works in a single page environment. I now want to migrate it to a master page. Any ideas will be greatly appreciated. I already searched this site and tried a couple of the suggestions to no avail. W small working example would help.
Thanks
Bill
Just take what you have in your single page and place it in the master page. It is really that simple. :) Then just replace the main body of the HTML in the master page with the content sections and you should be ready to go.
One thing I did discover was that for some reason the derived page had to be in the same folder as the master page.
Most likely caused by the master page referencing a subdirectory that works for the master page, but not the internal pages themselves. One workaround would be using
ScriptManager.RegisterClientScriptInclude(string Key, string URL)
like so:
ScriptManager.RegisterClientScriptInclude("uniqueIdentifier", "~/javascript/myjs.js");
Alternatively, you can embed the file as a resource and use
ScriptManager.RegisterClientScriptResource(Page, Type, Key);
like so:
ScriptManager.RegisterClientScriptResource(this.Page, typeOf(Page), "resourceKey");
this is my current favourite, seems to be most robust and flexible. Simply include the js files in your master then create an isntance on your pages
be sure to use the scriptmanager class to add the javascript