Click here to Skip to main content
15,880,725 members
Please Sign up or sign in to vote.
4.00/5 (3 votes)
See more:
Hi
I have a textbox and button on my page. if i insert a textbox value by using button click into my Database(SQL Serv2005) table, It'll display successfully inserted by using window.alert of Javascript for Confirmation. how to go about it and how to link javascript function from the button_Onclick event, where we can give code connecting to DB?

please some one help me ....

Mahesh

OP's Comment moved from Answer

Thank you very much you ALL ....... its working!!!!!
Posted
Updated 21-May-11 17:47pm
v2
Comments
Wonde Tadesse 21-May-11 13:05pm    
Elaborate.

Use this line after your insert statement,-

ScriptManager.RegisterClientScriptBlock(this.Page, this.GetType(), "ff", "alert('Informations are submitted successfully');", true);


Hope this can help you.
 
Share this answer
 
Comments
Wonde Tadesse 21-May-11 13:18pm    
The OP need a confirmation not an alert. You may have to change it to confirm("..."), instead of alert("...")
Prasanta_Prince 21-May-11 13:55pm    
then i have posting another one for confirm.
try this and just place this code where you want :

XML
string script = "<script type='text/javascript'>alert('successfully inserted.');</script>";
                   Page page = HttpContext.Current.CurrentHandler as Page;
                   if (!(page.ClientScript.IsClientScriptBlockRegistered("alert")))
                   {

                       page.ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", script);
                   }
 
Share this answer
 
You can make an AJAX call and respond to the message you get back. Or you can do a postback, and insert js to show the message that is appropriate.
 
Share this answer
 
OnClientClick="return confirm(\'Sure to Insert?  \');"
 
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