Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Presenting confirm dialogs from server side code
Message
 
To
12/12/2003 11:44:46
General information
Forum:
ASP.NET
Category:
Other
Miscellaneous
Thread ID:
00858238
Message ID:
00858756
Views:
19
>Now as far as that Attibutes collection and adding a handler, that's where I'm a little lost. I did see that idea in some things that I read, but I don't really get it. Will have to take a look at that in more detail later.

You don't really need to worry about this if you can get the text you need in there at the design time. IOW, if the text is static just put it in there. If it's dynamic you can still get it into the HTML using classic ASP tags (<%= this.Caption %> for example).

If you rather do it in code you can use the Form's Attribute collection and add the onsubmit handler. For example:

this.form1.Attributes.Add("onsubmit","alert('form submitting');return true;");

This is the same thing as attaching the onsubmit handler within the HTML, but it gives you control to do this in code so if you need to customize the message or code logic you cna do that here nicely.

In addition there are RegisterClientScriptBlock and RegisterStartupScript which can set up script functions and client code that fires when a form loads.

In essence you can do whatever you do in script in the HTML through code.

I'm not a big fan of doing this though, because unless you really have some logic that requires processing during the generation, there's no need to stick this stuff into your code. It only makes the server code more confusing and less readable...
+++ Rick ---

West Wind Technologies
Maui, Hawaii

west-wind.com/
West Wind Message Board
Rick's Web Log
Markdown Monster
---
Making waves on the Web

Where do you want to surf today?
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform