fire button event programmatically

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default fire button event programmatically

    From an aspx page (A.aspx) I open another one (B.aspx -
    for table lookup). When the user selects an entry in
    B.aspx I would like to force a button's event in A.aspx
    to be fired. I guess the only way is using javascript -
    does anybody have a sample for this ?
    Thanks
    Carlo Marchesoni Guest

  2. Similar Questions and Discussions

    1. composite control does not fire event
      Hi I have an aspx-page, where I load my custom-control (see below). The problem I have is that the event does not fire. I really cant figure out...
    2. Timer.Elapsed event doesn't want to fire
      I am trying to learn how to use the System.Timers.Timer control to perform an action every certain amount of time. However, the Elapsed event...
    3. Button.Init? how Do I know if click event has been fired? TextBox.TextChanged event before Button.Click in a CompositeCustomControl.
      Hello I have the following situation: (everything is dynamic (controls.add)) 1. Button.Init { WasButtonClickFired = true } 2....
    4. how to fire a postback event
      Hi, All I design a composite custom control, which has three dropdownlists in it. I find as long as one of the dropdownlist control's id is...
    5. Button in WebCustomControl don't fire the onclick event, why?
      Maybe someone sees my mistake? The Button-OnClick-Event never fires... -------------------------------------------------------- The code from...
  3. #2

    Default RE: fire button event programmatically

    Lewis,
    It looks interesting but I thing something went lost
    during copy/paste, your code stops right when it starts
    to become interesting.
    Thanks
    >-----Original Message-----
    >Thanks, Steve for the suggestions.
    >
    >Carlo, here is a sample for your reference.
    >
    >WebForm1.aspx:
    >There is a href and a Button1[server control] on it.
    >
    ><a
    >href="javascript:test=window.open
    ('WebForm2.aspx','test','width=300,height=1
    >88');test.focus()">TEST</a>
    >
    >Button1'event:
    >
    >private void Button1_Click(object sender,
    System.EventArgs e)
    >{
    >Response.Write ("Button1_Clicked~!");
    >}
    >
    >WebForm2.aspx:
    >
    >Drag a Literal control and a Button1 from the Toolbox to
    the page.
    >
    >private void Button1_Click(object sender,
    System.EventArgs e)
    >{
    >string strjscript = "<script language='javascript'>alert
    ('fire');";
    > strjscript += "window.opener.Form1.Button1.click
    ();";
    >//Form1 is the default form name of WebForm1.aspx
    > strjscript += "</script" + ">";
    > Literal1.Text = strjscript;
    >}
    >
    >Please let me know if it meets your need. Thanks.
    >
    >Hope this helps
    >
    >Lewis
    >
    >This posting is provided "AS IS" with no warranties, and
    confers no rights.
    >
    >
    >--------------------
    >| Content-Class: urn:content-classes:message
    >| From: "Carlo Marchesoni" <carloma@trix.com>
    >| Sender: "Carlo Marchesoni" <carloma@trix.com>
    >| Subject: fire button event programmatically
    >| Date: Tue, 29 Jul 2003 11:12:20 -0700
    >| Lines: 6
    >| Message-ID: <019001c355fc$f39147d0$a401280a@phx.gbl>
    >| MIME-Version: 1.0
    >| Content-Type: text/plain;
    >| charset="iso-8859-1"
    >| Content-Transfer-Encoding: 7bit
    >| X-Newsreader: Microsoft CDO for Windows 2000
    >| Thread-Index: AcNV/PORCJM8aNh4SiaWEZ4VauLzTg==
    >| X-MimeOLE: Produced By Microsoft MimeOLE
    V5.50.4910.0300
    >| Newsgroups: microsoft.public.dotnet.framework.aspnet
    >| Path: cpmsftngxa06.phx.gbl
    >| Xref: cpmsftngxa06.phx.gbl
    microsoft.public.dotnet.framework.aspnet:163071
    >| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
    >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    >|
    >| From an aspx page (A.aspx) I open another one (B.aspx -
    >| for table lookup). When the user selects an entry in
    >| B.aspx I would like to force a button's event in
    A.aspx
    >| to be fired. I guess the only way is using javascript -
    >| does anybody have a sample for this ?
    >| Thanks
    >|
    >
    >.
    >
    Carlo Marchesoni Guest

  4. #3

    Default RE: fire button event programmatically

    Hi Carlo,

    Thank you for your reply.

    The sample in my previous reply is just a snippet for demonstration.

    I would also like to recommend one good article to you.
    [url]http://aspnet.4guysfromrolla.com/articles/030202-1.aspx[/url]

    Please let me know if you need more information, thanks.

    Best Regards

    Lewis

    --------------------
    | Content-Class: urn:content-classes:message
    | From: "Carlo Marchesoni" <carloma@trix.com>
    | Sender: "Carlo Marchesoni" <carloma@trix.com>
    | References: <019001c355fc$f39147d0$a401280a@phx.gbl>
    <Ch3eBalVDHA.2240@cpmsftngxa06.phx.gbl>
    | Subject: RE: fire button event programmatically
    | Date: Tue, 29 Jul 2003 23:39:35 -0700
    | Lines: 88
    | Message-ID: <070a01c35665$572f0210$a601280a@phx.gbl>
    | MIME-Version: 1.0
    | Content-Type: text/plain;
    | charset="iso-8859-1"
    | Content-Transfer-Encoding: 7bit
    | X-Newsreader: Microsoft CDO for Windows 2000
    | X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
    | Thread-Index: AcNWZVcsxsK24TmkRNiO/8+BKduVCw==
    | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | Path: cpmsftngxa06.phx.gbl
    | Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:163243
    | NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    |
    | Lewis,
    | It looks interesting but I thing something went lost
    | during copy/paste, your code stops right when it starts
    | to become interesting.
    | Thanks
    | >-----Original Message-----
    | >Thanks, Steve for the suggestions.
    | >
    | >Carlo, here is a sample for your reference.
    | >
    | >WebForm1.aspx:
    | >There is a href and a Button1[server control] on it.
    | >
    | ><a
    | >href="javascript:test=window.open
    | ('WebForm2.aspx','test','width=300,height=1
    | >88');test.focus()">TEST</a>
    | >
    | >Button1'event:
    | >
    | >private void Button1_Click(object sender,
    | System.EventArgs e)
    | >{
    | >Response.Write ("Button1_Clicked~!");
    | >}
    | >
    | >WebForm2.aspx:
    | >
    | >Drag a Literal control and a Button1 from the Toolbox to
    | the page.
    | >
    | >private void Button1_Click(object sender,
    | System.EventArgs e)
    | >{
    | >string strjscript = "<script language='javascript'>alert
    | ('fire');";
    | > strjscript += "window.opener.Form1.Button1.click
    | ();";
    | >//Form1 is the default form name of WebForm1.aspx
    | > strjscript += "</script" + ">";
    | > Literal1.Text = strjscript;
    | >}
    | >
    | >Please let me know if it meets your need. Thanks.
    | >
    | >Hope this helps
    | >
    | >Lewis
    | >
    | >This posting is provided "AS IS" with no warranties, and
    | confers no rights.
    | >
    | >
    | >--------------------
    | >| Content-Class: urn:content-classes:message
    | >| From: "Carlo Marchesoni" <carloma@trix.com>
    | >| Sender: "Carlo Marchesoni" <carloma@trix.com>
    | >| Subject: fire button event programmatically
    | >| Date: Tue, 29 Jul 2003 11:12:20 -0700
    | >| Lines: 6
    | >| Message-ID: <019001c355fc$f39147d0$a401280a@phx.gbl>
    | >| MIME-Version: 1.0
    | >| Content-Type: text/plain;
    | >| charset="iso-8859-1"
    | >| Content-Transfer-Encoding: 7bit
    | >| X-Newsreader: Microsoft CDO for Windows 2000
    | >| Thread-Index: AcNV/PORCJM8aNh4SiaWEZ4VauLzTg==
    | >| X-MimeOLE: Produced By Microsoft MimeOLE
    | V5.50.4910.0300
    | >| Newsgroups: microsoft.public.dotnet.framework.aspnet
    | >| Path: cpmsftngxa06.phx.gbl
    | >| Xref: cpmsftngxa06.phx.gbl
    | microsoft.public.dotnet.framework.aspnet:163071
    | >| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
    | >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    | >|
    | >| From an aspx page (A.aspx) I open another one (B.aspx -
    | >| for table lookup). When the user selects an entry in
    | >| B.aspx I would like to force a button's event in
    | A.aspx
    | >| to be fired. I guess the only way is using javascript -
    |
    | >| does anybody have a sample for this ?
    | >| Thanks
    | >|
    | >
    | >.
    | >
    |

    Lewis Wang [MSFT] Guest

  5. #4

    Default RE: fire button event programmatically

    Did you attach a file ? I just see 'here is a sample...'
    and then WebForm1.aspx and WebForm1.aspx.cs but no
    attachement and no reference to something else.
    I don't understand.
    Thanks for your help
    >-----Original Message-----
    >Hi Carlo,
    >
    >Yes, you are right. It's not hard to fire a code-behind
    event from
    >javascript.
    >
    >Here is a sample to fire a code-behind event from
    javascript. It works fine
    >on my side, you can try it on your side.
    >
    >//when we click Button2, Button1's event will be fired
    from javascript.
    >
    >WebForm1.aspx
    >WebForm1.aspx.cs
    >
    >Check this link for more information:
    ><[url]http://groups.google.com/groups?[/url]
    q=fire+an+event+javascript+yhhuang+click&hl
    >=en&lr=&ie=UTF-8&oe=UTF-8&selm=xsSGTcBUDHA.2724%
    40cpmsftngxa06.phx.gbl&rnum=
    >1>
    >
    >Please review my first post and you will know how to
    fire an event form
    >another page, thanks.
    >
    >Does this answer your question? Please let me know if
    you need more
    >information.
    >
    >Best Regards,
    >Lewis
    >
    >This posting is provided "AS IS" with no warranties, and
    confers no rights.
    >
    >
    >
    >--------------------
    >| Content-Class: urn:content-classes:message
    >| From: "Carlo Marchesoni" <carloma@trix.com>
    >| Sender: "Carlo Marchesoni" <carloma@trix.com>
    >| References: <019001c355fc$f39147d0$a401280a@phx.gbl>
    ><Ch3eBalVDHA.2240@cpmsftngxa06.phx.gbl>
    ><070a01c35665$572f0210$a601280a@phx.gbl>
    ><wPDIZtnVDHA.2080@cpmsftngxa06.phx.gbl>
    >| Subject: RE: fire button event programmatically
    >| Date: Wed, 30 Jul 2003 03:52:08 -0700
    >| Lines: 150
    >| Message-ID: <0b5101c35688$9f20be10$a301280a@phx.gbl>
    >| MIME-Version: 1.0
    >| Content-Type: text/plain;
    >| charset="iso-8859-1"
    >| Content-Transfer-Encoding: 7bit
    >| X-Newsreader: Microsoft CDO for Windows 2000
    >| X-MIMEOLE: Produced By Microsoft MimeOLE
    V5.50.4910.0300
    >| Thread-Index: AcNWiJ8cNpvbvIvxSYCetBeJ8RXIdw==
    >| Newsgroups: microsoft.public.dotnet.framework.aspnet
    >| Path: cpmsftngxa06.phx.gbl
    >| Xref: cpmsftngxa06.phx.gbl
    microsoft.public.dotnet.framework.aspnet:163297
    >| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
    >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    >|
    >| Sorry that I still don't get it - the article is
    >| interesting and I manage to do it all, but this just
    >| shows how to load values in the window.opener (or at
    >| least that's what I understood). But I still don't see
    >| how you can fire a code-behind event. At the end the
    >| question probably is: how to fire code-behind event
    from
    >| javascript.
    >| Thanks for your help
    >| >-----Original Message-----
    >| >Hi Carlo,
    >| >
    >| >Thank you for your reply.
    >| >
    >| >The sample in my previous reply is just a snippet for
    >| demonstration.
    >| >
    >| >I would also like to recommend one good article to
    you.
    >| >[url]http://aspnet.4guysfromrolla.com/articles/030202-[/url]
    1.aspx
    >| >
    >| >Please let me know if you need more information,
    thanks.
    >| >
    >| >Best Regards
    >| >
    >| >Lewis
    >| >
    >| >--------------------
    >| >| Content-Class: urn:content-classes:message
    >| >| From: "Carlo Marchesoni" <carloma@trix.com>
    >| >| Sender: "Carlo Marchesoni" <carloma@trix.com>
    >| >| References: <019001c355fc$f39147d0
    $a401280a@phx.gbl>
    >| ><Ch3eBalVDHA.2240@cpmsftngxa06.phx.gbl>
    >| >| Subject: RE: fire button event programmatically
    >| >| Date: Tue, 29 Jul 2003 23:39:35 -0700
    >| >| Lines: 88
    >| >| Message-ID: <070a01c35665$572f0210$a601280a@phx.gbl>
    >| >| MIME-Version: 1.0
    >| >| Content-Type: text/plain;
    >| >| charset="iso-8859-1"
    >| >| Content-Transfer-Encoding: 7bit
    >| >| X-Newsreader: Microsoft CDO for Windows 2000
    >| >| X-MimeOLE: Produced By Microsoft MimeOLE
    >| V5.50.4910.0300
    >| >| Thread-Index: AcNWZVcsxsK24TmkRNiO/8+BKduVCw==
    >| >| Newsgroups: microsoft.public.dotnet.framework.aspnet
    >| >| Path: cpmsftngxa06.phx.gbl
    >| >| Xref: cpmsftngxa06.phx.gbl
    >| microsoft.public.dotnet.framework.aspnet:163243
    >| >| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
    >| >| X-Tomcat-NG:
    microsoft.public.dotnet.framework.aspnet
    >| >|
    >| >| Lewis,
    >| >| It looks interesting but I thing something went
    lost
    >| >| during copy/paste, your code stops right when it
    >| starts
    >| >| to become interesting.
    >| >| Thanks
    >| >| >-----Original Message-----
    >| >| >Thanks, Steve for the suggestions.
    >| >| >
    >| >| >Carlo, here is a sample for your reference.
    >| >| >
    >| >| >WebForm1.aspx:
    >| >| >There is a href and a Button1[server control] on
    it.
    >| >| >
    >| >| ><a
    >| >| >href="javascript:test=window.open
    >| >| ('WebForm2.aspx','test','width=300,height=1
    >| >| >88');test.focus()">TEST</a>
    >| >| >
    >| >| >Button1'event:
    >| >| >
    >| >| >private void Button1_Click(object sender,
    >| >| System.EventArgs e)
    >| >| >{
    >| >| >Response.Write ("Button1_Clicked~!");
    >| >| >}
    >| >| >
    >| >| >WebForm2.aspx:
    >| >| >
    >| >| >Drag a Literal control and a Button1 from the
    Toolbox
    >| to
    >| >| the page.
    >| >| >
    >| >| >private void Button1_Click(object sender,
    >| >| System.EventArgs e)
    >| >| >{
    >| >| >string strjscript = "<script
    >| language='javascript'>alert
    >| >| ('fire');";
    >| >| > strjscript += "window.opener.Form1.Button1.click
    >| >| ();";
    >| >| >//Form1 is the default form name of WebForm1.aspx
    >| >| > strjscript += "</script" + ">";
    >| >| > Literal1.Text = strjscript;
    >| >| >}
    >| >| >
    >| >| >Please let me know if it meets your need. Thanks.
    >| >| >
    >| >| >Hope this helps
    >| >| >
    >| >| >Lewis
    >| >| >
    >| >| >This posting is provided "AS IS" with no
    warranties,
    >| and
    >| >| confers no rights.
    >| >| >
    >| >| >
    >| >| >--------------------
    >| >| >| Content-Class: urn:content-classes:message
    >| >| >| From: "Carlo Marchesoni" <carloma@trix.com>
    >| >| >| Sender: "Carlo Marchesoni" <carloma@trix.com>
    >| >| >| Subject: fire button event programmatically
    >| >| >| Date: Tue, 29 Jul 2003 11:12:20 -0700
    >| >| >| Lines: 6
    >| >| >| Message-ID: <019001c355fc$f39147d0
    $a401280a@phx.gbl>
    >| >| >| MIME-Version: 1.0
    >| >| >| Content-Type: text/plain;
    >| >| >| charset="iso-8859-1"
    >| >| >| Content-Transfer-Encoding: 7bit
    >| >| >| X-Newsreader: Microsoft CDO for Windows 2000
    >| >| >| Thread-Index: AcNV/PORCJM8aNh4SiaWEZ4VauLzTg==
    >| >| >| X-MimeOLE: Produced By Microsoft MimeOLE
    >| >| V5.50.4910.0300
    >| >| >| Newsgroups:
    microsoft.public.dotnet.framework.aspnet
    >| >| >| Path: cpmsftngxa06.phx.gbl
    >| >| >| Xref: cpmsftngxa06.phx.gbl
    >| >| microsoft.public.dotnet.framework.aspnet:163071
    >| >| >| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
    >| >| >| X-Tomcat-NG:
    >| microsoft.public.dotnet.framework.aspnet
    >| >| >|
    >| >| >| From an aspx page (A.aspx) I open another one
    >| (B.aspx -
    >| >| >| for table lookup). When the user selects an
    entry
    >| in
    >| >| >| B.aspx I would like to force a button's event in
    >| >| A.aspx
    >| >| >| to be fired. I guess the only way is using
    >| javascript -
    >| >|
    >| >| >| does anybody have a sample for this ?
    >| >| >| Thanks
    >| >| >|
    >| >| >
    >| >| >.
    >| >| >
    >| >|
    >| >
    >| >.
    >| >
    >|
    Carlo Marchesoni Guest

  6. #5

    Default RE: fire button event programmatically

    That easy .... ! Thanks a million times, it works.
    >-----Original Message-----
    >Hi Carlo,
    >
    >Yes, I attached two files in my prior post.
    >
    >I will send them to your mailbox. If your mail address
    is invalid, please
    >send the correct one to me(remove "online") . Thanks.
    >
    >Best Regards,
    >Lewis Wang
    >
    >This posting is provided "AS IS" with no warranties, and
    confers no rights.
    >
    >--------------------
    >| Content-Class: urn:content-classes:message
    >| From: "Carlo Marchesoni" <carloma@trix.com>
    >| Sender: "Carlo Marchesoni" <carloma@trix.com>
    >| References: <019001c355fc$f39147d0$a401280a@phx.gbl>
    ><Ch3eBalVDHA.2240@cpmsftngxa06.phx.gbl>
    ><070a01c35665$572f0210$a601280a@phx.gbl>
    ><wPDIZtnVDHA.2080@cpmsftngxa06.phx.gbl>
    ><0b5101c35688$9f20be10$a301280a@phx.gbl>
    ><dfcSQtqVDHA.2276@cpmsftngxa06.phx.gbl>
    >| Subject: RE: fire button event programmatically
    >| Date: Wed, 30 Jul 2003 09:58:08 -0700
    >| Lines: 236
    >| Message-ID: <0eeb01c356bb$c0767e50$a501280a@phx.gbl>
    >| MIME-Version: 1.0
    >| Content-Type: text/plain;
    >| charset="iso-8859-1"
    >| Content-Transfer-Encoding: 7bit
    >| X-Newsreader: Microsoft CDO for Windows 2000
    >| X-MimeOLE: Produced By Microsoft MimeOLE
    V5.50.4910.0300
    >| Thread-Index: AcNWu8B2jmMFBxsnR9CnHhmhAAxTNg==
    >| Newsgroups: microsoft.public.dotnet.framework.aspnet
    >| Path: cpmsftngxa06.phx.gbl
    >| Xref: cpmsftngxa06.phx.gbl
    microsoft.public.dotnet.framework.aspnet:163444
    >| NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
    >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    >|
    >| Did you attach a file ? I just see 'here is a
    sample...'
    >| and then WebForm1.aspx and WebForm1.aspx.cs but no
    >| attachement and no reference to something else.
    >| I don't understand.
    >| Thanks for your help
    >| >-----Original Message-----
    >| >Hi Carlo,
    >| >
    >| >Yes, you are right. It's not hard to fire a code-
    behind
    >| event from
    >| >javascript.
    >| >
    >| >Here is a sample to fire a code-behind event from
    >| javascript. It works fine
    >| >on my side, you can try it on your side.
    >| >
    >| >//when we click Button2, Button1's event will be
    fired
    >| from javascript.
    >| >
    >| >WebForm1.aspx
    >| >WebForm1.aspx.cs
    >| >
    >| >Check this link for more information:
    >| ><[url]http://groups.google.com/groups?[/url]
    >| q=fire+an+event+javascript+yhhuang+click&hl
    >| >=en&lr=&ie=UTF-8&oe=UTF-8&selm=xsSGTcBUDHA.2724%
    >| 40cpmsftngxa06.phx.gbl&rnum=
    >| >1>
    >| >
    >| >Please review my first post and you will know how to
    >| fire an event form
    >| >another page, thanks.
    >| >
    >| >Does this answer your question? Please let me know if
    >| you need more
    >| >information.
    >| >
    >| >Best Regards,
    >| >Lewis
    >| >
    >| >This posting is provided "AS IS" with no warranties,
    and
    >| confers no rights.
    >| >
    >| >
    >| >
    >| >--------------------
    >| >| Content-Class: urn:content-classes:message
    >| >| From: "Carlo Marchesoni" <carloma@trix.com>
    >| >| Sender: "Carlo Marchesoni" <carloma@trix.com>
    >| >| References: <019001c355fc$f39147d0
    $a401280a@phx.gbl>
    >| ><Ch3eBalVDHA.2240@cpmsftngxa06.phx.gbl>
    >| ><070a01c35665$572f0210$a601280a@phx.gbl>
    >| ><wPDIZtnVDHA.2080@cpmsftngxa06.phx.gbl>
    >| >| Subject: RE: fire button event programmatically
    >| >| Date: Wed, 30 Jul 2003 03:52:08 -0700
    >| >| Lines: 150
    >| >| Message-ID: <0b5101c35688$9f20be10$a301280a@phx.gbl>
    >| >| MIME-Version: 1.0
    >| >| Content-Type: text/plain;
    >| >| charset="iso-8859-1"
    >| >| Content-Transfer-Encoding: 7bit
    >| >| X-Newsreader: Microsoft CDO for Windows 2000
    >| >| X-MIMEOLE: Produced By Microsoft MimeOLE
    >| V5.50.4910.0300
    >| >| Thread-Index: AcNWiJ8cNpvbvIvxSYCetBeJ8RXIdw==
    >| >| Newsgroups: microsoft.public.dotnet.framework.aspnet
    >| >| Path: cpmsftngxa06.phx.gbl
    >| >| Xref: cpmsftngxa06.phx.gbl
    >| microsoft.public.dotnet.framework.aspnet:163297
    >| >| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
    >| >| X-Tomcat-NG:
    microsoft.public.dotnet.framework.aspnet
    >| >|
    >| >| Sorry that I still don't get it - the article is
    >| >| interesting and I manage to do it all, but this
    just
    >| >| shows how to load values in the window.opener (or
    at
    >| >| least that's what I understood). But I still don't
    see
    >| >| how you can fire a code-behind event. At the end
    the
    >| >| question probably is: how to fire code-behind event
    >| from
    >| >| javascript.
    >| >| Thanks for your help
    >| >| >-----Original Message-----
    >| >| >Hi Carlo,
    >| >| >
    >| >| >Thank you for your reply.
    >| >| >
    >| >| >The sample in my previous reply is just a snippet
    for
    >| >| demonstration.
    >| >| >
    >| >| >I would also like to recommend one good article to
    >| you.
    >| >| >[url]http://aspnet.4guysfromrolla.com/articles/030202-[/url]
    >| 1.aspx
    >| >| >
    >| >| >Please let me know if you need more information,
    >| thanks.
    >| >| >
    >| >| >Best Regards
    >| >| >
    >| >| >Lewis
    >| >| >
    >| >| >--------------------
    >| >| >| Content-Class: urn:content-classes:message
    >| >| >| From: "Carlo Marchesoni" <carloma@trix.com>
    >| >| >| Sender: "Carlo Marchesoni" <carloma@trix.com>
    >| >| >| References: <019001c355fc$f39147d0
    >| $a401280a@phx.gbl>
    >| >| ><Ch3eBalVDHA.2240@cpmsftngxa06.phx.gbl>
    >| >| >| Subject: RE: fire button event programmatically
    >| >| >| Date: Tue, 29 Jul 2003 23:39:35 -0700
    >| >| >| Lines: 88
    >| >| >| Message-ID: <070a01c35665$572f0210
    $a601280a@phx.gbl>
    >| >| >| MIME-Version: 1.0
    >| >| >| Content-Type: text/plain;
    >| >| >| charset="iso-8859-1"
    >| >| >| Content-Transfer-Encoding: 7bit
    >| >| >| X-Newsreader: Microsoft CDO for Windows 2000
    >| >| >| X-MimeOLE: Produced By Microsoft MimeOLE
    >| >| V5.50.4910.0300
    >| >| >| Thread-Index: AcNWZVcsxsK24TmkRNiO/8+BKduVCw==
    >| >| >| Newsgroups:
    microsoft.public.dotnet.framework.aspnet
    >| >| >| Path: cpmsftngxa06.phx.gbl
    >| >| >| Xref: cpmsftngxa06.phx.gbl
    >| >| microsoft.public.dotnet.framework.aspnet:163243
    >| >| >| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
    >| >| >| X-Tomcat-NG:
    >| microsoft.public.dotnet.framework.aspnet
    >| >| >|
    >| >| >| Lewis,
    >| >| >| It looks interesting but I thing something went
    >| lost
    >| >| >| during copy/paste, your code stops right when it
    >| >| starts
    >| >| >| to become interesting.
    >| >| >| Thanks
    >| >| >| >-----Original Message-----
    >| >| >| >Thanks, Steve for the suggestions.
    >| >| >| >
    >| >| >| >Carlo, here is a sample for your reference.
    >| >| >| >
    >| >| >| >WebForm1.aspx:
    >| >| >| >There is a href and a Button1[server control]
    on
    >| it.
    >| >| >| >
    >| >| >| ><a
    >| >| >| >href="javascript:test=window.open
    >| >| >| ('WebForm2.aspx','test','width=300,height=1
    >| >| >| >88');test.focus()">TEST</a>
    >| >| >| >
    >| >| >| >Button1'event:
    >| >| >| >
    >| >| >| >private void Button1_Click(object sender,
    >| >| >| System.EventArgs e)
    >| >| >| >{
    >| >| >| >Response.Write ("Button1_Clicked~!");
    >| >| >| >}
    >| >| >| >
    >| >| >| >WebForm2.aspx:
    >| >| >| >
    >| >| >| >Drag a Literal control and a Button1 from the
    >| Toolbox
    >| >| to
    >| >| >| the page.
    >| >| >| >
    >| >| >| >private void Button1_Click(object sender,
    >| >| >| System.EventArgs e)
    >| >| >| >{
    >| >| >| >string strjscript = "<script
    >| >| language='javascript'>alert
    >| >| >| ('fire');";
    >| >| >| > strjscript
    += "window.opener.Form1.Button1.click
    >| >| >| ();";
    >| >| >| >//Form1 is the default form name of
    WebForm1.aspx
    >| >| >| > strjscript += "</script" + ">";
    >| >| >| > Literal1.Text = strjscript;
    >| >| >| >}
    >| >| >| >
    >| >| >| >Please let me know if it meets your need.
    Thanks.
    >| >| >| >
    >| >| >| >Hope this helps
    >| >| >| >
    >| >| >| >Lewis
    >| >| >| >
    >| >| >| >This posting is provided "AS IS" with no
    >| warranties,
    >| >| and
    >| >| >| confers no rights.
    >| >| >| >
    >| >| >| >
    >| >| >| >--------------------
    >| >| >| >| Content-Class: urn:content-classes:message
    >| >| >| >| From: "Carlo Marchesoni" <carloma@trix.com>
    >| >| >| >| Sender: "Carlo Marchesoni" <carloma@trix.com>
    >| >| >| >| Subject: fire button event programmatically
    >| >| >| >| Date: Tue, 29 Jul 2003 11:12:20 -0700
    >| >| >| >| Lines: 6
    >| >| >| >| Message-ID: <019001c355fc$f39147d0
    >| $a401280a@phx.gbl>
    >| >| >| >| MIME-Version: 1.0
    >| >| >| >| Content-Type: text/plain;
    >| >| >| >| charset="iso-8859-1"
    >| >| >| >| Content-Transfer-Encoding: 7bit
    >| >| >| >| X-Newsreader: Microsoft CDO for Windows 2000
    >| >| >| >| Thread-Index: AcNV/PORCJM8aNh4SiaWEZ4VauLzTg==
    >| >| >| >| X-MimeOLE: Produced By Microsoft MimeOLE
    >| >| >| V5.50.4910.0300
    >| >| >| >| Newsgroups:
    >| microsoft.public.dotnet.framework.aspnet
    >| >| >| >| Path: cpmsftngxa06.phx.gbl
    >| >| >| >| Xref: cpmsftngxa06.phx.gbl
    >| >| >| microsoft.public.dotnet.framework.aspnet:163071
    >| >| >| >| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
    >| >| >| >| X-Tomcat-NG:
    >| >| microsoft.public.dotnet.framework.aspnet
    >| >| >| >|
    >| >| >| >| From an aspx page (A.aspx) I open another one
    >| >| (B.aspx -
    >| >| >| >| for table lookup). When the user selects an
    >| entry
    >| >| in
    >| >| >| >| B.aspx I would like to force a button's event
    in
    >| >| >| A.aspx
    >| >| >| >| to be fired. I guess the only way is using
    >| >| javascript -
    >| >| >|
    >| >| >| >| does anybody have a sample for this ?
    >| >| >| >| Thanks
    >| >| >| >|
    >| >| >| >
    >| >| >| >.
    >| >| >| >
    >| >| >|
    >| >| >
    >| >| >.
    >| >| >
    >| >|
    >|
    >
    >.
    >
    Carlo Marchesoni Guest

  7. #6

    Default RE: fire button event programmatically

    Hi Carlo,

    I am glad to hear that. :) Thanks very much for participating the community.

    Best Regards,
    Lewis

    Get Secure! - [url]www.microsoft.com/security[/url]
    This posting is provided "AS IS" with no warranties, and confers no rights.



    --------------------
    | Content-Class: urn:content-classes:message
    | From: "Carlo Marchesoni" <carloma@trix.com>
    | Sender: "Carlo Marchesoni" <carloma@trix.com>
    | References: <019001c355fc$f39147d0$a401280a@phx.gbl>
    <Ch3eBalVDHA.2240@cpmsftngxa06.phx.gbl>
    <070a01c35665$572f0210$a601280a@phx.gbl>
    <wPDIZtnVDHA.2080@cpmsftngxa06.phx.gbl>
    <0b5101c35688$9f20be10$a301280a@phx.gbl>
    <dfcSQtqVDHA.2276@cpmsftngxa06.phx.gbl>
    <0eeb01c356bb$c0767e50$a501280a@phx.gbl>
    <s7Ez8WwVDHA.1996@cpmsftngxa06.phx.gbl>
    | Subject: RE: fire button event programmatically
    | Date: Thu, 31 Jul 2003 05:21:35 -0700
    | Lines: 303
    | Message-ID: <597701c3575e$48abb220$a001280a@phx.gbl>
    | MIME-Version: 1.0
    | Content-Type: text/plain;
    | charset="iso-8859-1"
    | Content-Transfer-Encoding: 7bit
    | X-Newsreader: Microsoft CDO for Windows 2000
    | X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
    | Thread-Index: AcNXXkirlgpFq1oTQpG6ry/rcX8KHg==
    | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | Path: cpmsftngxa06.phx.gbl
    | Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:163717
    | NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    |
    | That easy .... ! Thanks a million times, it works.
    | >-----Original Message-----
    | >Hi Carlo,
    | >
    | >Yes, I attached two files in my prior post.
    | >
    | >I will send them to your mailbox. If your mail address
    | is invalid, please
    | >send the correct one to me(remove "online") . Thanks.
    | >
    | >Best Regards,
    | >Lewis Wang
    | >
    | >This posting is provided "AS IS" with no warranties, and
    | confers no rights.
    | >
    | >--------------------
    | >| Content-Class: urn:content-classes:message
    | >| From: "Carlo Marchesoni" <carloma@trix.com>
    | >| Sender: "Carlo Marchesoni" <carloma@trix.com>
    | >| References: <019001c355fc$f39147d0$a401280a@phx.gbl>
    | ><Ch3eBalVDHA.2240@cpmsftngxa06.phx.gbl>
    | ><070a01c35665$572f0210$a601280a@phx.gbl>
    | ><wPDIZtnVDHA.2080@cpmsftngxa06.phx.gbl>
    | ><0b5101c35688$9f20be10$a301280a@phx.gbl>
    | ><dfcSQtqVDHA.2276@cpmsftngxa06.phx.gbl>
    | >| Subject: RE: fire button event programmatically
    | >| Date: Wed, 30 Jul 2003 09:58:08 -0700
    | >| Lines: 236
    | >| Message-ID: <0eeb01c356bb$c0767e50$a501280a@phx.gbl>
    | >| MIME-Version: 1.0
    | >| Content-Type: text/plain;
    | >| charset="iso-8859-1"
    | >| Content-Transfer-Encoding: 7bit
    | >| X-Newsreader: Microsoft CDO for Windows 2000
    | >| X-MimeOLE: Produced By Microsoft MimeOLE
    | V5.50.4910.0300
    | >| Thread-Index: AcNWu8B2jmMFBxsnR9CnHhmhAAxTNg==
    | >| Newsgroups: microsoft.public.dotnet.framework.aspnet
    | >| Path: cpmsftngxa06.phx.gbl
    | >| Xref: cpmsftngxa06.phx.gbl
    | microsoft.public.dotnet.framework.aspnet:163444
    | >| NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
    | >| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    | >|
    | >| Did you attach a file ? I just see 'here is a
    | sample...'
    | >| and then WebForm1.aspx and WebForm1.aspx.cs but no
    | >| attachement and no reference to something else.
    | >| I don't understand.
    | >| Thanks for your help
    | >| >-----Original Message-----
    | >| >Hi Carlo,
    | >| >
    | >| >Yes, you are right. It's not hard to fire a code-
    | behind
    | >| event from
    | >| >javascript.
    | >| >
    | >| >Here is a sample to fire a code-behind event from
    | >| javascript. It works fine
    | >| >on my side, you can try it on your side.
    | >| >
    | >| >//when we click Button2, Button1's event will be
    | fired
    | >| from javascript.
    | >| >
    | >| >WebForm1.aspx
    | >| >WebForm1.aspx.cs
    | >| >
    | >| >Check this link for more information:
    | >| ><[url]http://groups.google.com/groups?[/url]
    | >| q=fire+an+event+javascript+yhhuang+click&hl
    | >| >=en&lr=&ie=UTF-8&oe=UTF-8&selm=xsSGTcBUDHA.2724%
    | >| 40cpmsftngxa06.phx.gbl&rnum=
    | >| >1>
    | >| >
    | >| >Please review my first post and you will know how to
    | >| fire an event form
    | >| >another page, thanks.
    | >| >
    | >| >Does this answer your question? Please let me know if
    | >| you need more
    | >| >information.
    | >| >
    | >| >Best Regards,
    | >| >Lewis
    | >| >
    | >| >This posting is provided "AS IS" with no warranties,
    | and
    | >| confers no rights.
    | >| >
    | >| >
    | >| >
    | >| >--------------------
    | >| >| Content-Class: urn:content-classes:message
    | >| >| From: "Carlo Marchesoni" <carloma@trix.com>
    | >| >| Sender: "Carlo Marchesoni" <carloma@trix.com>
    | >| >| References: <019001c355fc$f39147d0
    | $a401280a@phx.gbl>
    | >| ><Ch3eBalVDHA.2240@cpmsftngxa06.phx.gbl>
    | >| ><070a01c35665$572f0210$a601280a@phx.gbl>
    | >| ><wPDIZtnVDHA.2080@cpmsftngxa06.phx.gbl>
    | >| >| Subject: RE: fire button event programmatically
    | >| >| Date: Wed, 30 Jul 2003 03:52:08 -0700
    | >| >| Lines: 150
    | >| >| Message-ID: <0b5101c35688$9f20be10$a301280a@phx.gbl>
    | >| >| MIME-Version: 1.0
    | >| >| Content-Type: text/plain;
    | >| >| charset="iso-8859-1"
    | >| >| Content-Transfer-Encoding: 7bit
    | >| >| X-Newsreader: Microsoft CDO for Windows 2000
    | >| >| X-MIMEOLE: Produced By Microsoft MimeOLE
    | >| V5.50.4910.0300
    | >| >| Thread-Index: AcNWiJ8cNpvbvIvxSYCetBeJ8RXIdw==
    | >| >| Newsgroups: microsoft.public.dotnet.framework.aspnet
    | >| >| Path: cpmsftngxa06.phx.gbl
    | >| >| Xref: cpmsftngxa06.phx.gbl
    | >| microsoft.public.dotnet.framework.aspnet:163297
    | >| >| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
    | >| >| X-Tomcat-NG:
    | microsoft.public.dotnet.framework.aspnet
    | >| >|
    | >| >| Sorry that I still don't get it - the article is
    | >| >| interesting and I manage to do it all, but this
    | just
    | >| >| shows how to load values in the window.opener (or
    | at
    | >| >| least that's what I understood). But I still don't
    | see
    | >| >| how you can fire a code-behind event. At the end
    | the
    | >| >| question probably is: how to fire code-behind event
    | >| from
    | >| >| javascript.
    | >| >| Thanks for your help
    | >| >| >-----Original Message-----
    | >| >| >Hi Carlo,
    | >| >| >
    | >| >| >Thank you for your reply.
    | >| >| >
    | >| >| >The sample in my previous reply is just a snippet
    | for
    | >| >| demonstration.
    | >| >| >
    | >| >| >I would also like to recommend one good article to
    | >| you.
    | >| >| >[url]http://aspnet.4guysfromrolla.com/articles/030202-[/url]
    | >| 1.aspx
    | >| >| >
    | >| >| >Please let me know if you need more information,
    | >| thanks.
    | >| >| >
    | >| >| >Best Regards
    | >| >| >
    | >| >| >Lewis
    | >| >| >
    | >| >| >--------------------
    | >| >| >| Content-Class: urn:content-classes:message
    | >| >| >| From: "Carlo Marchesoni" <carloma@trix.com>
    | >| >| >| Sender: "Carlo Marchesoni" <carloma@trix.com>
    | >| >| >| References: <019001c355fc$f39147d0
    | >| $a401280a@phx.gbl>
    | >| >| ><Ch3eBalVDHA.2240@cpmsftngxa06.phx.gbl>
    | >| >| >| Subject: RE: fire button event programmatically
    | >| >| >| Date: Tue, 29 Jul 2003 23:39:35 -0700
    | >| >| >| Lines: 88
    | >| >| >| Message-ID: <070a01c35665$572f0210
    | $a601280a@phx.gbl>
    | >| >| >| MIME-Version: 1.0
    | >| >| >| Content-Type: text/plain;
    | >| >| >| charset="iso-8859-1"
    | >| >| >| Content-Transfer-Encoding: 7bit
    | >| >| >| X-Newsreader: Microsoft CDO for Windows 2000
    | >| >| >| X-MimeOLE: Produced By Microsoft MimeOLE
    | >| >| V5.50.4910.0300
    | >| >| >| Thread-Index: AcNWZVcsxsK24TmkRNiO/8+BKduVCw==
    | >| >| >| Newsgroups:
    | microsoft.public.dotnet.framework.aspnet
    | >| >| >| Path: cpmsftngxa06.phx.gbl
    | >| >| >| Xref: cpmsftngxa06.phx.gbl
    | >| >| microsoft.public.dotnet.framework.aspnet:163243
    | >| >| >| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
    | >| >| >| X-Tomcat-NG:
    | >| microsoft.public.dotnet.framework.aspnet
    | >| >| >|
    | >| >| >| Lewis,
    | >| >| >| It looks interesting but I thing something went
    | >| lost
    | >| >| >| during copy/paste, your code stops right when it
    | >| >| starts
    | >| >| >| to become interesting.
    | >| >| >| Thanks
    | >| >| >| >-----Original Message-----
    | >| >| >| >Thanks, Steve for the suggestions.
    | >| >| >| >
    | >| >| >| >Carlo, here is a sample for your reference.
    | >| >| >| >
    | >| >| >| >WebForm1.aspx:
    | >| >| >| >There is a href and a Button1[server control]
    | on
    | >| it.
    | >| >| >| >
    | >| >| >| ><a
    | >| >| >| >href="javascript:test=window.open
    | >| >| >| ('WebForm2.aspx','test','width=300,height=1
    | >| >| >| >88');test.focus()">TEST</a>
    | >| >| >| >
    | >| >| >| >Button1'event:
    | >| >| >| >
    | >| >| >| >private void Button1_Click(object sender,
    | >| >| >| System.EventArgs e)
    | >| >| >| >{
    | >| >| >| >Response.Write ("Button1_Clicked~!");
    | >| >| >| >}
    | >| >| >| >
    | >| >| >| >WebForm2.aspx:
    | >| >| >| >
    | >| >| >| >Drag a Literal control and a Button1 from the
    | >| Toolbox
    | >| >| to
    | >| >| >| the page.
    | >| >| >| >
    | >| >| >| >private void Button1_Click(object sender,
    | >| >| >| System.EventArgs e)
    | >| >| >| >{
    | >| >| >| >string strjscript = "<script
    | >| >| language='javascript'>alert
    | >| >| >| ('fire');";
    | >| >| >| > strjscript
    | += "window.opener.Form1.Button1.click
    | >| >| >| ();";
    | >| >| >| >//Form1 is the default form name of
    | WebForm1.aspx
    | >| >| >| > strjscript += "</script" + ">";
    | >| >| >| > Literal1.Text = strjscript;
    | >| >| >| >}
    | >| >| >| >
    | >| >| >| >Please let me know if it meets your need.
    | Thanks.
    | >| >| >| >
    | >| >| >| >Hope this helps
    | >| >| >| >
    | >| >| >| >Lewis
    | >| >| >| >
    | >| >| >| >This posting is provided "AS IS" with no
    | >| warranties,
    | >| >| and
    | >| >| >| confers no rights.
    | >| >| >| >
    | >| >| >| >
    | >| >| >| >--------------------
    | >| >| >| >| Content-Class: urn:content-classes:message
    | >| >| >| >| From: "Carlo Marchesoni" <carloma@trix.com>
    | >| >| >| >| Sender: "Carlo Marchesoni" <carloma@trix.com>
    | >| >| >| >| Subject: fire button event programmatically
    | >| >| >| >| Date: Tue, 29 Jul 2003 11:12:20 -0700
    | >| >| >| >| Lines: 6
    | >| >| >| >| Message-ID: <019001c355fc$f39147d0
    | >| $a401280a@phx.gbl>
    | >| >| >| >| MIME-Version: 1.0
    | >| >| >| >| Content-Type: text/plain;
    | >| >| >| >| charset="iso-8859-1"
    | >| >| >| >| Content-Transfer-Encoding: 7bit
    | >| >| >| >| X-Newsreader: Microsoft CDO for Windows 2000
    | >| >| >| >| Thread-Index: AcNV/PORCJM8aNh4SiaWEZ4VauLzTg==
    | >| >| >| >| X-MimeOLE: Produced By Microsoft MimeOLE
    | >| >| >| V5.50.4910.0300
    | >| >| >| >| Newsgroups:
    | >| microsoft.public.dotnet.framework.aspnet
    | >| >| >| >| Path: cpmsftngxa06.phx.gbl
    | >| >| >| >| Xref: cpmsftngxa06.phx.gbl
    | >| >| >| microsoft.public.dotnet.framework.aspnet:163071
    | >| >| >| >| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
    | >| >| >| >| X-Tomcat-NG:
    | >| >| microsoft.public.dotnet.framework.aspnet
    | >| >| >| >|
    | >| >| >| >| From an aspx page (A.aspx) I open another one
    | >| >| (B.aspx -
    | >| >| >| >| for table lookup). When the user selects an
    | >| entry
    | >| >| in
    | >| >| >| >| B.aspx I would like to force a button's event
    | in
    | >| >| >| A.aspx
    | >| >| >| >| to be fired. I guess the only way is using
    | >| >| javascript -
    | >| >| >|
    | >| >| >| >| does anybody have a sample for this ?
    | >| >| >| >| Thanks
    | >| >| >| >|
    | >| >| >| >
    | >| >| >| >.
    | >| >| >| >
    | >| >| >|
    | >| >| >
    | >| >| >.
    | >| >| >
    | >| >|
    | >|
    | >
    | >.
    | >
    |

    Lewis Wang [MSFT] Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139