Message box in asp.net

R

ratnakarp

hi,

i want to pop up a message box when a button is clicked. the situation
is something like this as follows.


protected void button1_click(.. , ..)
{
.......
........
.......

response.write(<script language="javascript"> or
language="vbscript">confirm or msgbox or etc..</script>)
if(clicked yes)
{
do the following

}
else
get out of the method

}


is there any way if user clicks yes on the confirm box or message box,
the rest of the code in button1 click method should be executed
otherwise get out of the method. Any help or reference is appreciated.

Thanks,
Ratnakar Pedagani
 
G

Guest

btn.Attributes.Add("onClick", "return confirm('Do you really want to delete
the record?');");

HTH

Elton Wang
 
R

ratnakarp

Hello Elton,

Thanks for your reply, but here i'm facing the problem., i forgot to
add a condition. i changed the code. In the following code, if the
cond1 is true, then the confirm message should pop up. if clicked yes,
i should be able to do something else within button click method. for
example

protected void button1_click(.. , ..)
{
x=callmethod1();
y=callmethod2();
z=str1;

if(z>40)
{
//pop up confirm box, "do you want to continue"
response.write(<script language="javascript"> or
language="vbscript">confirm or msgbox or etc..</script>)
if(clicked yes)
{
save the details in the database;
}
else
{
get out of the method
}
}

can you please let me know how to proceed further. Kindly let me know
if you need to know anything else.

Thanks & Regards,
Ratnakar Pedagani.
 
G

Guest

You should know that client-server (Web) application is different from
desktop one. Especially, in server-side code you can’t directly interact with
user. What I can suggest is to put your logic on client-side (javascript
function(s)). Only when postback, on server-side to save detail to DB:

Server Code:
Page_Load(){
// ...
btn.Attributes.Add("onClick", "return CheckZ();");
}

btn_Click(...)
{
// save info;
}

Client code:

<script>
function CheckZ()
{
var z = getZ;
if(z <=40)
{
return false;
}
Return confirm(confirm message);
}
</script>


HTH
 
R

ratnakarp

Do you guyz got any other ideaz, looks like these things are not
working for me? Thanks for your help

Regards,
Ratnakar Pedagani
 

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

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top