Reputation: 566
I need a technique for dealing with what seems pretty simple!
I have a form, with some logic on the server side for validation. if the server side code indicates that there is an issue, I want to display a modal popup to the client.
I am having trouble getting it to work in this way.
I found if I keep all the logic client side, I can use the javascript function
window.showModalDialog("url","title", "style");
However the logic is currently on the server side. this is an ASP.NET 3.5 web project - is there some way to do this using AJAX controls like the scriptmanager, an update panel etc?
Thank you!
Upvotes: 3
Views: 3368
Reputation: 5513
You really shouldn't use the modal popuper. First of all it mstly works only in IE. Second of all it's REALLY annoying for your end users...
You should rather use something like e.g. this;Ra-Ajax Clendar Starter-Kit (click the "Create New Activity" in the bottom left corner)
Upvotes: 0
Reputation: 8633
I know that you do it using the ScriptManager control. Basically you just send from the server a line of JavaScript to execute immediately. In this case, the client side line you describe.
Sorry to be vague, but it's almost quitting time and I'll have to grep through a lot of code to find an example.
Upvotes: 2
Reputation: 23878
Beware that modal dialogs are not supported in all browsers.
You may be able to accomplish something similar using DHTML and setting the visibility of divs from the server side if your server side validation fails.
You might also look at Telerik's RadWindow control which was designed (in part) to solve the modal dialog problem.
Upvotes: 1
Reputation: 23935
You need to use an AJAX callback to perform your server side validation and return a response to the client - then decide whether to display the modal dialog... however, why do you need to validate on the server? It is usually best to try and validate in the client to save roundtrips...
Upvotes: 0