Click here to Skip to main content
15,884,388 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi how I can Prompt div as dialog by c# .net in web application without using any kind of dll and can get response and based on response (Overwrite/Append/Ignore) can continue execution of code which is maintained by if-else.

thanks in advance
Posted
Updated 9-May-11 2:46am
v3

1 solution

you first need to understand how Client-Server process in ASP.NET works.

1- Client requests only and Server serves only. remember HTTP protocol.

2- Client is HTML + Javascript. Hence whatever you want to show on client must be converted to client's standard
Custom Javascript Dialog in ASP.NET[^]

3- Server is c# asp.net.
Most common impression is people treat web application as procedural language like winform application, you click a button.. button click event will be raised .. in click method user will popup some message and so on.

But it is not like that. its like this:
1- user requests a page like: http://www.somewebsite.com/home.aspx with some header information like browser type/version etc.
2- IIS gives this to Asp.net and asp.net checks there is nothing else in request i.e. no querystring and no form elements that means it is requested first time. (remember IsPostBack)
3- asp.net reads the home.aspx file and create a dll adding some more lines to create instance of Web.Page class.
4- Then the home.aspx.cs as dll comes into the picture and initializes all of its controls.
5- finally every control is rendered that means HTML and Javascript is created for client end, and send.
6- user clicks on a asp;button in browser. The browser will send request back to home.aspx but this time with Form and its element + the object who triggered the event i.e. button clicked
7- IIS gives this to ASP.net and because this time the request has form also it creates Reqeust object with form/querystring elements and adds it to HttpContext so that user can access all of its elements.
8- when home.aspx.cs comes into the picture it initializes all of its controls and after page load event it checks for any event raiser information and binds the event to asp:button control at server side and then button raises the event.
9- when all code statments in button_click methods are completed the page process rest of the events and unload itself and finally sends its rendered html to client. Now if you want to send anything from button_click method you need to add it to Response objects output property and then Response.flush/end. But the dll will its no more in picture go asp.net will unload the page and its dll and send the response to client.

The AJAX gives you feel of async process but it works on HTTP.

so you need to keep all the point in mind and then design your functionality.

For example in your case:
1- Add some javascript function say ShowWindow() and on click of some button invoke it.
2- ShowWindow will show your custom dialogbox at client end and clicking of any button inside it set some value in hidden field and submit the page back to server.
3- in button click method add your code based on the value in hidden field.

Thanks,
Hemant
 
Share this answer
 
Comments
Sandeep Mewara 9-May-11 10:57am    
My 5+!
Sergey Alexandrovich Kryukov 9-May-11 22:15pm    
Nice explanation, my 5.
--SA
Ashishmau 10-May-11 0:30am    
perfect 5+++
Hemant__Sharma 10-May-11 1:33am    
Thank you all. when an Expert vote up for an answer that matters a lot.
Thanks a lot once again.

Regards,
Hemant
trilokharry 10-May-11 5:28am    
thanks for your kind response.

I can call modelpopupextender by c# code but not able to get response in same place of code.

see my requirement as mentioned below:

//after click on ok it should return something and closed and rest of the code will be executed based on response

string strResponse = this.programmaticModalPopup.Show();

if(strResponse == "Append")

{

//code

}

else if(strResponse == "Overwrite")

{

//code

}

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900