469,904 Members | 2,046 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,904 developers. It's quick & easy.

How can I raise Web Server Button control Click event twice? & JavaScript

I want to open a popup window when user click the web server button
control

When user click the button, only OnClik="OpenWindow(12)" is sent
but no event happend no popup opened.After that, user click again
popup window is open. So user must click twice!
So I must raise event twice. How can I do that or do you advice any
solution?

Thanks!
private void btnPopupWindow_Click(object sender,System.EventArgs e)
{
btnPopupWindow.Attributes.Add("OnClick","OpenWindo w('" + x +
"')");
// call btnPopupWindow_Click(---,---); ??? It must be called
again to open popup
}
Nov 18 '05 #1
2 3852
Hi,
Put the following peace of your code in the Button pre render event :

btnPopupWindow.Attributes.Add("OnClick","OpenWindo w('" + x + "')");

This will deff work.
Currently what is happening is that after you press the button once the JS
is getting registered at that time.
So when you are clicking on the second time the JS is getting fired then.
Regards,
Zuzar L.

"Oney" <oz*********@yahoo.com> wrote in message
news:cc**************************@posting.google.c om...
I want to open a popup window when user click the web server button
control

When user click the button, only OnClik="OpenWindow(12)" is sent
but no event happend no popup opened.After that, user click again
popup window is open. So user must click twice!
So I must raise event twice. How can I do that or do you advice any
solution?

Thanks!
private void btnPopupWindow_Click(object sender,System.EventArgs e)
{
btnPopupWindow.Attributes.Add("OnClick","OpenWindo w('" + x +
"')");
// call btnPopupWindow_Click(---,---); ??? It must be called
again to open popup
}

Nov 18 '05 #2
Hi,

You don't need to raise event twice. you can use button attributes on
Page_Load to add button client side script that catch click event,
display message and just then continue and submit the page to server :

this.Button1.Attributes.Add("onclick","return ss_onclick()");

function ss_onclick(){
window.showModalDialog("a.aspx");
{

you can even cancel postback from your client script function by setting
window.event.returnValue to false.

Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

12 posts views Thread by HarveyB | last post: by
1 post views Thread by Perry van Kuppeveld | last post: by
22 posts views Thread by Mr Newbie | last post: by
2 posts views Thread by Dave | last post: by
6 posts views Thread by den 2005 | last post: by
reply views Thread by Roberto Kohler | last post: by
1 post views Thread by Waqarahmed | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.