I have problem in asp.net with java script

Posted by Nuwan under ASP.NET on 11/13/2012 | Points: 10 | Views : 896 | Status : [Member] | Replies : 2
I want to insert data using asp.net web application.
First I want to read in data base that record number already exits in the data base.
after i want to show confirmation message box Like, If record number already exits Do you a want really continue Confirmation and
if click OK Record save with same record number.

Please help me that matter



Posted by: Santhi on: 11/14/2012 [Member] Starter | Points: 25


Call the javascript function from the c# if the record exists for the same number.
Try In this way.

<script type="text/javascript">
function ConfirmSave() {
if (confirm(' really continue Confirmation?')) {
document.getElementById('<%= Button1.ClientID %>').click();

call this script from the C# where the record exists:

ClientScriptManager cs = Page.ClientScript;
cs.RegisterStartupScript(this.GetType(), "ConfirmSave", "ConfirmSave()", true);

On the buttonclick event right the save record steps.

Thanks && Regards,
V. Santhi

Thanks & Regards,
Santhi .V

Nuwan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Funda on: 11/14/2012 [Member] Starter | Points: 25

If you are using Asp.Net 3.5 and above use Script manager...

///If the record is exist in DB Call This in Server Side.Which will call the JavaScrip Confrim POP UP

ScriptManager.RegisterStartupScript(Page, GetType(), "disp_confirm", "<script>disp_confirm()</script>", false);

<script type="text/javascript">

function disp_confirm() {
var r = jConfirm("Record is already exits! Do you a want really continue")
if (r == true) {
PageMethods.ProcessIT(); ///Add Parameter if you want.This will call the C# Method directly from JavaScript
/// You can handel sucess as well error for ProcessIT() , If you want...
/// function onSucess(result) {
/// alert(result);
/// }
/// function onError(result) {
/// alert('Something wrong.');
/// }

else {
jAlert("You pressed Cancel!")

/// Which will be called from Java Script , If you want you can return the value back to JavaScript

public static string ProcessIT() ///Add Parameter if you want to get the value from Javascript.
string result = "Done";
return result;

Nuwan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response