Can we make confirm as a common function

A

ad

We must do with Javascirpt when develop web UI.
I write a alert function which can call from server side like:

public static void alert(Page myPage, string sMsg)
{
string myScritpt;
myScritpt = "<script> window.alert('"+sMsg+"');</script>";

myPage.RegisterStartupScript("", myScritpt);
}

I can call the alert function like:
alert (this, "my message");

I want to wrte a confirm as alert do, so I can call the confirm function
like:
if (confirm("Are you sure"))
{
.......
}

How can I write the confirm function?
 
G

Grant Merwitz

Place this in your page load, pointint it to your button you want the
confirm on:

btnMyButton.Attributes.Add("OnClick", "JavaScript: return confirm('Are you
sure');");
 
C

Curt_C [MVP]

ad said:
We must do with Javascirpt when develop web UI.
I write a alert function which can call from server side like:

public static void alert(Page myPage, string sMsg)
{
string myScritpt;
myScritpt = "<script> window.alert('"+sMsg+"');</script>";

myPage.RegisterStartupScript("", myScritpt);
}

I can call the alert function like:
alert (this, "my message");

I want to wrte a confirm as alert do, so I can call the confirm function
like:
if (confirm("Are you sure"))
{
......
}

How can I write the confirm function?

just pass the confirm() into the individual buttons clientside onClick
event.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top