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

O

Oney

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","OpenWindow('" + x +
"')");
// call btnPopupWindow_Click(---,---); ??? It must be called
again to open popup
}
 
Z

Zuzar Lakdawala

Hi,
Put the following peace of your code in the Button pre render event :

btnPopupWindow.Attributes.Add("OnClick","OpenWindow('" + 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.
 
N

Natty Gur

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
 

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

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top