Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
ASP .Net
ASPX now with methods and classes
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="John Horst, post: 477651"] Good grief... You can always escape the double quotes. Response.Write("<input type=\"button\" onclick=\"alert('this is a message')\">"); will do what you are talking about. And when you talk about libraries for rendering HTML, that is exactly what ASP.NET server controls are. As an example, the Label control is a library that renders a <span> tag with the label text as the innerText of the element. If you wanted something to happen client side when the user clicks on the span, you would do something like this in your codebehind. this.lblTest.Attributes.Add("onclick", "alert('You clicked me!');"); this.lblTest.Text = "Click me!"; The server would then replace the <asp:Label runat="server" id="lblTest"...></asp:Label> in the aspx page with this: <span id="lblTest" onclick="alert('You clicked me!');">Click me!</span> before sending the response to the browser. ASP.NET, from the Page class to all of the server controls, is nothing but a bunch of rendering libraries. But what it does is allow you to apply OOP to web programming. The TextBox class, for example, renders an <input> tag. I recently created a class that inherits from TextBox and adds color properties so a programmer can specify at design time one back color when the text box gets the focus (say yellow) and another when it loses the focus (normal white). All I have to do is drop that control on a page and I get all the standard textbox functionality plus my client side onfocus and onblur events. Additionally, the rendering happens both in the VS designer surface as well as the browser at runtime, so you can use standard HTML to organize a page and server controls to handle the dynamic stuff. If you use typed datasets you can actually have complex pages with grids that all look at design time pretty much like what the user will see. Get a book on server controls and actually start to write a couple and you'll have a much better understanding of ASP.NET and why the kind of rendering you're talking about is not supported at the page level (server controls make it unnecessary). In an earlier post you said you did not like user controls. On that I agree. Once you get your head wrapped around server controls, user controls kind of lose their appeal, not to mention that server controls are more reusable. John [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
ASP .Net
ASPX now with methods and classes
Top