By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,652 Members | 1,682 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,652 IT Pros & Developers. It's quick & easy.

Need help on popping up a java script popup box when clicked on a LinkButton.

P: n/a
Hello,
I have two buttons on one of my VehicleDetails.aspx page. Obiviously
these two buttons takes the user to two different pages. Now my client
is interested in having a linkbutton instead of the two buttons. Once
the user clicks on the linkbutton a javascript dialog box popsup that
says "Is the Lessee buying this vehicle?" and with two buttons "Yes"
and "No". If user clicks "yes" it should go to DealerQuestions.aspx"
and if "No" it goes "lesseePurchase.aspx" page.

As of now I have two buttons like I mentioned earlier where in under
the button click event I am doing a Response.Redirect() to the said
pages.
could some one help me how do I accomplish the linkbutton and adding a
javascript functionality to it as I said on the top?

This is what I put to get the javascript popup box to popup when
clicked on the linkbutton

_lnkDLpurchase.Attributes.Add("onclick", "window.alert('Will Lessee buy
this vehicle?.');return true;")

But I don't know how to get two buttons and exectue two different codes
based on what was clicked on.
Please help,
Thanks in advance
-L

Jun 30 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"alert" is to show a a message with no buttons...
"prompt" is to show a question and a textbox where the user input something
and it will be used as a javascript variable
"confirm" is what you want, it shows a question with 2 buttons...

so change this:
_lnkDLpurchase.Attributes.Add("onclick", "window.alert('Will Lessee buy
this vehicle?.');return true;")

into this:
_lnkDLpurchase.Attributes.Add("onclick", "if( confirm('Will Lessee buy
this vehicle?') ) return true; else return false;")
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
"Learner" <pr****@gmail.com> escreveu na mensagem
news:11**********************@y41g2000cwy.googlegr oups.com...
Hello,
I have two buttons on one of my VehicleDetails.aspx page. Obiviously
these two buttons takes the user to two different pages. Now my client
is interested in having a linkbutton instead of the two buttons. Once
the user clicks on the linkbutton a javascript dialog box popsup that
says "Is the Lessee buying this vehicle?" and with two buttons "Yes"
and "No". If user clicks "yes" it should go to DealerQuestions.aspx"
and if "No" it goes "lesseePurchase.aspx" page.

As of now I have two buttons like I mentioned earlier where in under
the button click event I am doing a Response.Redirect() to the said
pages.
could some one help me how do I accomplish the linkbutton and adding a
javascript functionality to it as I said on the top?

This is what I put to get the javascript popup box to popup when
clicked on the linkbutton

_lnkDLpurchase.Attributes.Add("onclick", "window.alert('Will Lessee buy
this vehicle?.');return true;")

But I don't know how to get two buttons and exectue two different codes
based on what was clicked on.
Please help,
Thanks in advance
-L

Jun 30 '06 #2

P: n/a
Hello Bruno,
Good explanation. Now I understand the differences on how to get a
pop window based on our need. I test it and I get two buttons on the
popup box.

Now one more help. If uses clicks on "Yes" it should execute the code

Response.Redirect("LesseePurchase.aspx?DealerShipI D=" &
_lblDealerShipIDValue.Text)

when "No" this should go to another page

Response.Redirect("DealerQuestions.aspx?DealerShip ID=" &
_lblDealerShipIDValue.Text)

Could you also help me wih this one too?

Thanks
-L
Bruno Alexandre wrote:
"alert" is to show a a message with no buttons...
"prompt" is to show a question and a textbox where the user input something
and it will be used as a javascript variable
"confirm" is what you want, it shows a question with 2 buttons...

so change this:
_lnkDLpurchase.Attributes.Add("onclick", "window.alert('Will Lessee buy
this vehicle?.');return true;")

into this:
_lnkDLpurchase.Attributes.Add("onclick", "if( confirm('Will Lessee buy
this vehicle?') ) return true; else return false;")
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
"Learner" <pr****@gmail.com> escreveu na mensagem
news:11**********************@y41g2000cwy.googlegr oups.com...
Hello,
I have two buttons on one of my VehicleDetails.aspx page. Obiviously
these two buttons takes the user to two different pages. Now my client
is interested in having a linkbutton instead of the two buttons. Once
the user clicks on the linkbutton a javascript dialog box popsup that
says "Is the Lessee buying this vehicle?" and with two buttons "Yes"
and "No". If user clicks "yes" it should go to DealerQuestions.aspx"
and if "No" it goes "lesseePurchase.aspx" page.

As of now I have two buttons like I mentioned earlier where in under
the button click event I am doing a Response.Redirect() to the said
pages.
could some one help me how do I accomplish the linkbutton and adding a
javascript functionality to it as I said on the top?

This is what I put to get the javascript popup box to popup when
clicked on the linkbutton

_lnkDLpurchase.Attributes.Add("onclick", "window.alert('Will Lessee buy
this vehicle?.');return true;")

But I don't know how to get two buttons and exectue two different codes
based on what was clicked on.
Please help,
Thanks in advance
-L


Jun 30 '06 #3

P: n/a
L,
From your last post, I don't think you want to mess with Javascript. You can't easily convert that Javascript response into a
Response.Redirect, since JS runs on the client, and the
response.redirect is on the server.

What I do in lieu of JS confirmations is create a separate aspx page
for the confirmation. The link button links to this page, and then you
bind the yes/no buttons to the Response.Redirects to the appropriate
pages from there.

So the two logic branches would be:

vehicle details page --> link button --> "Is the Lessee buying this
vehicle?" page --> yes button --> DealerQuestions page

-OR-

vehicle details page --> link button --> "Is the Lessee buying this
vehicle?" page --> no button --> LesseePurchase page

I hope this helps. I use this for Delete confirmations as well.

Thanks,
Gary

Learner wrote: Hello Bruno,
Good explanation. Now I understand the differences on how to get a
pop window based on our need. I test it and I get two buttons on the
popup box.

Now one more help. If uses clicks on "Yes" it should execute the code

Response.Redirect("LesseePurchase.aspx?DealerShipI D=" &
_lblDealerShipIDValue.Text)

when "No" this should go to another page

Response.Redirect("DealerQuestions.aspx?DealerShip ID=" &
_lblDealerShipIDValue.Text)

Could you also help me wih this one too?

Thanks
-L
Bruno Alexandre wrote:
"alert" is to show a a message with no buttons...
"prompt" is to show a question and a textbox where the user input something
and it will be used as a javascript variable
"confirm" is what you want, it shows a question with 2 buttons...

so change this:
_lnkDLpurchase.Attributes.Add("onclick", "window.alert('Will Lessee buy
this vehicle?.');return true;")

into this:
_lnkDLpurchase.Attributes.Add("onclick", "if( confirm('Will Lessee buy
this vehicle?') ) return true; else return false;")
--

Bruno Alexandre
(a Portuguese in Københanv, Danmark)
"Learner" <pr****@gmail.com> escreveu na mensagem
news:11**********************@y41g2000cwy.googlegr oups.com...
Hello,
I have two buttons on one of my VehicleDetails.aspx page. Obiviously
these two buttons takes the user to two different pages. Now my client
is interested in having a linkbutton instead of the two buttons. Once
the user clicks on the linkbutton a javascript dialog box popsup that
says "Is the Lessee buying this vehicle?" and with two buttons "Yes"
and "No". If user clicks "yes" it should go to DealerQuestions.aspx"
and if "No" it goes "lesseePurchase.aspx" page.

As of now I have two buttons like I mentioned earlier where in under
the button click event I am doing a Response.Redirect() to the said
pages.
could some one help me how do I accomplish the linkbutton and adding a
javascript functionality to it as I said on the top?

This is what I put to get the javascript popup box to popup when
clicked on the linkbutton

_lnkDLpurchase.Attributes.Add("onclick", "window.alert('Will Lessee buy
this vehicle?.');return true;")

But I don't know how to get two buttons and exectue two different codes
based on what was clicked on.
Please help,
Thanks in advance
-L


Jun 30 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.