JavaScript Confirm msgbox...

G

Guest

Hi,

I would like to ask something to user after user submits the form...
I know I can ask user whehter they want to submit the form or not using
client-script code such as onClick or onSubmit by adding into attributes
collections...

My problem is a little bit different than that...
I would like to ask user something after submission is done

Suppose that this is the behind code when user clicks the submit button...

private void btnSubmit_Click(object sender, System.EventArgs e)
{
//..blah..
//..blah...
//..blah...
//Form data will be saved into database...
//At this point, I would like to ask user something.like..
// if(confirm('Do you want to process more?') == true) {
// redirect to specific page with QueryParameters
// }
// else
// {
// redirect to main page..
// }

}

Any idea?

Thanks.
 
J

John MacIntyre

TJ said:
Hi, [snip]
My problem is a little bit different than that...
I would like to ask user something after submission is done

Suppose that this is the behind code when user clicks the submit button...

private void btnSubmit_Click(object sender, System.EventArgs e)
{
//..blah..
//..blah...
//..blah...
//Form data will be saved into database...
//At this point, I would like to ask user something.like..
// if(confirm('Do you want to process more?') == true) {
// redirect to specific page with QueryParameters
// }
// else
// {
// redirect to main page..
// }

IMHO-Create a new page for the 'Do you want to process more?' question.
Then redirect from there.
 
R

rviray

there are a couple of ways to do it, depending on your needs...but th
quickest that I can come up with is...

1) Create a new new page...say Redirect.aspx
2) From your button click event, do your DB stuff and build th
QueryParameters that you may use...concatenate Redirect.aspx?<Quer
Paramter>
3) On the Redirect.aspx page, have a javascript function tha
prompts...and depending on the prompt...do a Window.location....

if that doesn't work for you or post back and we can try a differen
method...
 
G

Guest

This is one method..

Create a javascript funtion as below (please note - Syntax is wrong. .this
is psudo code)
<script>
function Confirm(var QueryParameters)
{
if(window.confirm("'Do you want to process more?"))
{
//javascript code to redirect to specific page with QueryParameters

}
else
{
//javascript code to redirect to main page
}
}
</script>

in code behind after //Form data will be saved into database...

string QueryParameters = //construct query params here
Page.RegisterStartupScript("somename","<script>Confirm(' " + QueryParameters
+ " ') </script>")


When the code behind done with execution, it will emit a javascript to call
the javascript function "Confirm"
 

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,743
Messages
2,569,478
Members
44,898
Latest member
BlairH7607

Latest Threads

Top