Javascript in ASP.NET
-
-
Vector7 wrote: Is there a way that ASP.NET can access standard HTML Objects ( for example a hidden input field )`? hmm what do you mean? On server or on client? ASP.NET (or better
System.Web.UI.HtmlControls
namespace) provides classes - server side controls - to expose properties of HTML controls on server side. Basicaly addrunat="server"
to your HTML element and provide member variable of suitable "HtmlControl" class in your page class. If you want to acces HTML elements on client as you do with JS, you must use client script like JS or VBScript. Vector7 wrote: 2) Is it possible to start a javascript in ASP.NET at different places ( not at start like the standard ) Yes. What is standart, btw? Head tag? You can write your JS wherever you want - using standart ASP.NET functions ( as described in article) , attributes for Server controls (in article again), or you can even write JS code directly to page using inline script (<% %>) andResponse
object. (I don't know any reason for this right now, bt why not? :) ) Injecting Client-Side Script from an ASP.NET Server Control[^] hope it helps, best regards, David 'DNH' Nohejl Never forget: "Stay kul and happy" (I.A.) -
put a normal html button and make onclick=ur javasript function as exampl an a logout html button 1.write this code at the aspx page function logout(){ if(window.confirm("Are you sure u want to logout")) {window.navigate("../login.aspx?tona='ok'"); } } 2.write this button in the aspx page some thing like that :)
-
1. Asign the tag an id a nd specify the tag to be runat="server". eg:
protected System.Web.UI.HtmlControls.HtmlGenericControl styleLink;
tada... now you can access the element from code behind. eg:styleLink.Attributes.Add("href", "../css/nice.css");
2. Yes. How dow you mean?