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

Discussion in 'ASP .Net' started by Oney, May 16, 2004.

  1. Oney

    Oney Guest

    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
    }
    Oney, May 16, 2004
    #1
    1. Advertising

  2. 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.



    "Oney" <> wrote in message
    news:...
    > 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
    > }
    Zuzar Lakdawala, May 17, 2004
    #2
    1. Advertising

  3. Oney

    Natty Gur Guest

    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!
    Natty Gur, May 17, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Purvi T
    Replies:
    0
    Views:
    821
    Purvi T
    Oct 19, 2004
  2. mike parr
    Replies:
    1
    Views:
    459
    Marina
    May 20, 2004
  3. Amy
    Replies:
    0
    Views:
    961
  4. Roberto Kohler
    Replies:
    0
    Views:
    512
    Roberto Kohler
    Nov 6, 2007
  5. William
    Replies:
    2
    Views:
    726
    William
    Jan 18, 2008
Loading...

Share This Page