Javascript return value

G

Guest

Hi,

I have an asp.net page that has a LinkButton w/ attribute "onclick" = "javascript confirm('hello world');" How do I pass the value of the OK button back to my asp .net page? I could, put the function in the <head> section like...

<head>
<script language="javascript">
function CallMe()
{
if(confirm("hello world"))
{
// pass the OK value to asp.net page
}
else
{
// pass the cancel value to asp.net page
}
}
</script>
</head>
....
and have my LinkButton "onclick" attribute to call "CallMe()".

Please advice, thanks!
-P
 
S

Steve C. Orr [MVP, MCSD]

Here's some server side code that outputs javascript similar to what you are
requesting:
myDeleteButton.Attributes.Add("onclick", _
"return confirm('Are you sure you want to delete?');")

In this example, the Delete button will post back only if the person
confirms they want to delete. Otherwise your server code is never called in
response to the button click.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


Paul said:
Hi,

I have an asp.net page that has a LinkButton w/ attribute "onclick" =
"javascript confirm('hello world');" How do I pass the value of the OK
 
G

Guest

Yupe. I just got it to work. But I guess the most important thing is to set LinkButton.CommandName = "delete".

Thanks,
-P
 

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