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

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

P: n/a
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
Share this Question
Share on Google+
2 Replies


P: n/a
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

P: n/a
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.