Click here to Skip to main content
15,896,118 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
There are 2 types of javascript Dialog available:

1. alert : which have only OK button in it.
2. confirm : which has Ok and Cancel

but how v can use this without page refresh in asp.net
Posted

You should have edited your original question, as it's still what you're asking. Any button on a web page in ASP.NET can have a click event, and a client click. The client click event will be in javascript, and if it returns false, the OnClick will not postback. So, to avoid postback, you simply need to add the code to show the dialog box BEFORE you do a postback, so it's in the page already.
 
Share this answer
 
hi man,

if you use AJAX in your page you can call this code on required places

ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "test", "alert('welcome');");

on page load,
Page.ClientScript.RegisterStartupScript(typeof(Page), "MyScript", "alert('welcome');");

same as you should improve the question
 
Share this answer
 
Comments
rency1 11-Feb-11 2:08am    
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "test", "alert('welcome');");
This code is giving Error
I have tried the below code
ScriptManager.RegisterClientScriptBlock(this, typeof(Page), "test", "alert('welcome');", true);
I dont know why you require Postback to show alert / confirm.... :confused:

Just add alert in the client side and your alert will be displayed.

say <input type="button" onclick = "javascript:alert('hi');" />

Now if the button is clicked, it will show the alert. :)
 
Share this answer
 
Your question is not very clear. Can you please elaborate.

Whatever i can understand,

You will have to use
ClientScript.RegisterClientScriptBlock

or
controlName.Attributes.Add


Please improve your question.
 
Share this answer
 
Dear Amit,

Can you please clarrify your requirement, I have few questions.

1.Do you want to execute the functionality on page load or any event is implemented for this?

2.Is there any priority given on getting the dialog boxes.








Regards
Adarsh
 
Share this answer
 

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