fire button event programmatically

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Carlo Marchesoni

    #1

    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

    #2
    RE: fire button event programmaticall y

    Lewis,
    It looks interesting but I thing something went lost
    during copy/paste, your code stops right when it starts
    to become interesting.
    Thanks[color=blue]
    >-----Original Message-----
    >Thanks, Steve for the suggestions.
    >
    >Carlo, here is a sample for your reference.
    >
    >WebForm1.asp x:
    >There is a href and a Button1[server control] on it.
    >
    ><a
    >href="javascri pt:test=window. open[/color]
    ('WebForm2.aspx ','test','width =300,height=1[color=blue]
    >88');test.focu s()">TEST</a>
    >
    >Button1'even t:
    >
    >private void Button1_Click(o bject sender,[/color]
    System.EventArg s e)[color=blue]
    >{
    >Response.Wri te ("Button1_Click ed~!");
    >}
    >
    >WebForm2.asp x:
    >
    >Drag a Literal control and a Button1 from the Toolbox to[/color]
    the page.[color=blue]
    >
    >private void Button1_Click(o bject sender,[/color]
    System.EventArg s e)[color=blue]
    >{
    >string strjscript = "<script language='javas cript'>alert[/color]
    ('fire');";[color=blue]
    > strjscript += "window.opener. Form1.Button1.c lick[/color]
    ();";[color=blue]
    >//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[/color]
    confers no rights.[color=blue]
    >
    >
    >--------------------
    >| Content-Class: urn:content-classes:message
    >| From: "Carlo Marchesoni" <carloma@trix.c om>
    >| Sender: "Carlo Marchesoni" <carloma@trix.c om>
    >| Subject: fire button event programmaticall y
    >| Date: Tue, 29 Jul 2003 11:12:20 -0700
    >| Lines: 6
    >| Message-ID: <019001c355fc$f 39147d0$a401280 a@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/PORCJM8aNh4SiaW EZ4VauLzTg==
    >| X-MimeOLE: Produced By Microsoft MimeOLE[/color]
    V5.50.4910.0300[color=blue]
    >| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
    >| Path: cpmsftngxa06.ph x.gbl
    >| Xref: cpmsftngxa06.ph x.gbl[/color]
    microsoft.publi c.dotnet.framew ork.aspnet:1630 71[color=blue]
    >| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
    >| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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[/color]
    A.aspx[color=blue]
    >| to be fired. I guess the only way is using javascript -[/color]
    [color=blue]
    >| does anybody have a sample for this ?
    >| Thanks
    >|
    >
    >.
    >[/color]

    Comment

    • Lewis Wang [MSFT]

      #3
      RE: fire button event programmaticall y

      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.


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

      Best Regards

      Lewis

      --------------------
      | Content-Class: urn:content-classes:message
      | From: "Carlo Marchesoni" <carloma@trix.c om>
      | Sender: "Carlo Marchesoni" <carloma@trix.c om>
      | References: <019001c355fc$f 39147d0$a401280 a@phx.gbl>
      <Ch3eBalVDHA.22 40@cpmsftngxa06 .phx.gbl>
      | Subject: RE: fire button event programmaticall y
      | Date: Tue, 29 Jul 2003 23:39:35 -0700
      | Lines: 88
      | Message-ID: <070a01c35665$5 72f0210$a601280 a@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: AcNWZVcsxsK24Tm kRNiO/8+BKduVCw==
      | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
      | Path: cpmsftngxa06.ph x.gbl
      | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1632 43
      | NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
      | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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.asp x:
      | >There is a href and a Button1[server control] on it.
      | >
      | ><a
      | >href="javascri pt:test=window. open
      | ('WebForm2.aspx ','test','width =300,height=1
      | >88');test.focu s()">TEST</a>
      | >
      | >Button1'even t:
      | >
      | >private void Button1_Click(o bject sender,
      | System.EventArg s e)
      | >{
      | >Response.Wri te ("Button1_Click ed~!");
      | >}
      | >
      | >WebForm2.asp x:
      | >
      | >Drag a Literal control and a Button1 from the Toolbox to
      | the page.
      | >
      | >private void Button1_Click(o bject sender,
      | System.EventArg s e)
      | >{
      | >string strjscript = "<script language='javas cript'>alert
      | ('fire');";
      | > strjscript += "window.opener. Form1.Button1.c lick
      | ();";
      | >//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.c om>
      | >| Sender: "Carlo Marchesoni" <carloma@trix.c om>
      | >| Subject: fire button event programmaticall y
      | >| Date: Tue, 29 Jul 2003 11:12:20 -0700
      | >| Lines: 6
      | >| Message-ID: <019001c355fc$f 39147d0$a401280 a@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/PORCJM8aNh4SiaW EZ4VauLzTg==
      | >| X-MimeOLE: Produced By Microsoft MimeOLE
      | V5.50.4910.0300
      | >| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
      | >| Path: cpmsftngxa06.ph x.gbl
      | >| Xref: cpmsftngxa06.ph x.gbl
      | microsoft.publi c.dotnet.framew ork.aspnet:1630 71
      | >| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
      | >| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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
      | >|
      | >
      | >.
      | >
      |

      Comment

      • Carlo Marchesoni

        #4
        RE: fire button event programmaticall y

        Did you attach a file ? I just see 'here is a sample...'
        and then WebForm1.aspx and WebForm1.aspx.c s but no
        attachement and no reference to something else.
        I don't understand.
        Thanks for your help[color=blue]
        >-----Original Message-----
        >Hi Carlo,
        >
        >Yes, you are right. It's not hard to fire a code-behind[/color]
        event from[color=blue]
        >javascript.
        >
        >Here is a sample to fire a code-behind event from[/color]
        javascript. It works fine[color=blue]
        >on my side, you can try it on your side.
        >
        >//when we click Button2, Button1's event will be fired[/color]
        from javascript.[color=blue]
        >
        >WebForm1.asp x
        >WebForm1.aspx. cs
        >
        >Check this link for more information:
        ><http://groups.google.com/groups?[/color]
        q=fire+an+event +javascript+yhh uang+click&hl[color=blue]
        >=en&lr=&ie=U TF-8&oe=UTF-8&selm=xsSGTcBU DHA.2724%[/color]
        40cpmsftngxa06. phx.gbl&rnum=[color=blue]
        >1>
        >
        >Please review my first post and you will know how to[/color]
        fire an event form[color=blue]
        >another page, thanks.
        >
        >Does this answer your question? Please let me know if[/color]
        you need more[color=blue]
        >information.
        >
        >Best Regards,
        >Lewis
        >
        >This posting is provided "AS IS" with no warranties, and[/color]
        confers no rights.[color=blue]
        >
        >
        >
        >--------------------
        >| Content-Class: urn:content-classes:message
        >| From: "Carlo Marchesoni" <carloma@trix.c om>
        >| Sender: "Carlo Marchesoni" <carloma@trix.c om>
        >| References: <019001c355fc$f 39147d0$a401280 a@phx.gbl>
        ><Ch3eBalVDHA.2 240@cpmsftngxa0 6.phx.gbl>
        ><070a01c35665$ 572f0210$a60128 0a@phx.gbl>
        ><wPDIZtnVDHA.2 080@cpmsftngxa0 6.phx.gbl>
        >| Subject: RE: fire button event programmaticall y
        >| Date: Wed, 30 Jul 2003 03:52:08 -0700
        >| Lines: 150
        >| Message-ID: <0b5101c35688$9 f20be10$a301280 a@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[/color]
        V5.50.4910.0300[color=blue]
        >| Thread-Index: AcNWiJ8cNpvbvIv xSYCetBeJ8RXIdw ==
        >| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
        >| Path: cpmsftngxa06.ph x.gbl
        >| Xref: cpmsftngxa06.ph x.gbl[/color]
        microsoft.publi c.dotnet.framew ork.aspnet:1632 97[color=blue]
        >| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
        >| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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[/color]
        from[color=blue]
        >| 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[/color]
        you.[color=blue]
        >| >http://aspnet.4guysfromrolla.com/articles/030202-[/color]
        1.aspx[color=blue]
        >| >
        >| >Please let me know if you need more information,[/color]
        thanks.[color=blue]
        >| >
        >| >Best Regards
        >| >
        >| >Lewis
        >| >
        >| >--------------------
        >| >| Content-Class: urn:content-classes:message
        >| >| From: "Carlo Marchesoni" <carloma@trix.c om>
        >| >| Sender: "Carlo Marchesoni" <carloma@trix.c om>
        >| >| References: <019001c355fc$f 39147d0[/color]
        $a401280a@phx.g bl>[color=blue]
        >| ><Ch3eBalVDHA.2 240@cpmsftngxa0 6.phx.gbl>
        >| >| Subject: RE: fire button event programmaticall y
        >| >| Date: Tue, 29 Jul 2003 23:39:35 -0700
        >| >| Lines: 88
        >| >| Message-ID: <070a01c35665$5 72f0210$a601280 a@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: AcNWZVcsxsK24Tm kRNiO/8+BKduVCw==
        >| >| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
        >| >| Path: cpmsftngxa06.ph x.gbl
        >| >| Xref: cpmsftngxa06.ph x.gbl
        >| microsoft.publi c.dotnet.framew ork.aspnet:1632 43
        >| >| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
        >| >| X-Tomcat-NG:[/color]
        microsoft.publi c.dotnet.framew ork.aspnet[color=blue]
        >| >|
        >| >| Lewis,
        >| >| It looks interesting but I thing something went[/color]
        lost[color=blue]
        >| >| 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.asp x:
        >| >| >There is a href and a Button1[server control] on[/color]
        it.[color=blue]
        >| >| >
        >| >| ><a
        >| >| >href="javascri pt:test=window. open
        >| >| ('WebForm2.aspx ','test','width =300,height=1
        >| >| >88');test.focu s()">TEST</a>
        >| >| >
        >| >| >Button1'even t:
        >| >| >
        >| >| >private void Button1_Click(o bject sender,
        >| >| System.EventArg s e)
        >| >| >{
        >| >| >Response.Wri te ("Button1_Click ed~!");
        >| >| >}
        >| >| >
        >| >| >WebForm2.asp x:
        >| >| >
        >| >| >Drag a Literal control and a Button1 from the[/color]
        Toolbox[color=blue]
        >| to
        >| >| the page.
        >| >| >
        >| >| >private void Button1_Click(o bject sender,
        >| >| System.EventArg s e)
        >| >| >{
        >| >| >string strjscript = "<script
        >| language='javas cript'>alert
        >| >| ('fire');";
        >| >| > strjscript += "window.opener. Form1.Button1.c lick
        >| >| ();";
        >| >| >//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[/color]
        warranties,[color=blue]
        >| and
        >| >| confers no rights.
        >| >| >
        >| >| >
        >| >| >--------------------
        >| >| >| Content-Class: urn:content-classes:message
        >| >| >| From: "Carlo Marchesoni" <carloma@trix.c om>
        >| >| >| Sender: "Carlo Marchesoni" <carloma@trix.c om>
        >| >| >| Subject: fire button event programmaticall y
        >| >| >| Date: Tue, 29 Jul 2003 11:12:20 -0700
        >| >| >| Lines: 6
        >| >| >| Message-ID: <019001c355fc$f 39147d0[/color]
        $a401280a@phx.g bl>[color=blue]
        >| >| >| 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/PORCJM8aNh4SiaW EZ4VauLzTg==
        >| >| >| X-MimeOLE: Produced By Microsoft MimeOLE
        >| >| V5.50.4910.0300
        >| >| >| Newsgroups:[/color]
        microsoft.publi c.dotnet.framew ork.aspnet[color=blue]
        >| >| >| Path: cpmsftngxa06.ph x.gbl
        >| >| >| Xref: cpmsftngxa06.ph x.gbl
        >| >| microsoft.publi c.dotnet.framew ork.aspnet:1630 71
        >| >| >| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
        >| >| >| X-Tomcat-NG:
        >| microsoft.publi c.dotnet.framew ork.aspnet
        >| >| >|
        >| >| >| From an aspx page (A.aspx) I open another one
        >| (B.aspx -
        >| >| >| for table lookup). When the user selects an[/color]
        entry[color=blue]
        >| 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
        >| >| >|
        >| >| >
        >| >| >.
        >| >| >
        >| >|
        >| >
        >| >.
        >| >
        >|[/color]

        Comment

        • Carlo Marchesoni

          #5
          RE: fire button event programmaticall y

          That easy .... ! Thanks a million times, it works.[color=blue]
          >-----Original Message-----
          >Hi Carlo,
          >
          >Yes, I attached two files in my prior post.
          >
          >I will send them to your mailbox. If your mail address[/color]
          is invalid, please[color=blue]
          >send the correct one to me(remove "online") . Thanks.
          >
          >Best Regards,
          >Lewis Wang
          >
          >This posting is provided "AS IS" with no warranties, and[/color]
          confers no rights.[color=blue]
          >
          >--------------------
          >| Content-Class: urn:content-classes:message
          >| From: "Carlo Marchesoni" <carloma@trix.c om>
          >| Sender: "Carlo Marchesoni" <carloma@trix.c om>
          >| References: <019001c355fc$f 39147d0$a401280 a@phx.gbl>
          ><Ch3eBalVDHA.2 240@cpmsftngxa0 6.phx.gbl>
          ><070a01c35665$ 572f0210$a60128 0a@phx.gbl>
          ><wPDIZtnVDHA.2 080@cpmsftngxa0 6.phx.gbl>
          ><0b5101c35688$ 9f20be10$a30128 0a@phx.gbl>
          ><dfcSQtqVDHA.2 276@cpmsftngxa0 6.phx.gbl>
          >| Subject: RE: fire button event programmaticall y
          >| Date: Wed, 30 Jul 2003 09:58:08 -0700
          >| Lines: 236
          >| Message-ID: <0eeb01c356bb$c 0767e50$a501280 a@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[/color]
          V5.50.4910.0300[color=blue]
          >| Thread-Index: AcNWu8B2jmMFBxs nR9CnHhmhAAxTNg ==
          >| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
          >| Path: cpmsftngxa06.ph x.gbl
          >| Xref: cpmsftngxa06.ph x.gbl[/color]
          microsoft.publi c.dotnet.framew ork.aspnet:1634 44[color=blue]
          >| NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
          >| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
          >|
          >| Did you attach a file ? I just see 'here is a[/color]
          sample...'[color=blue]
          >| and then WebForm1.aspx and WebForm1.aspx.c s 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-[/color]
          behind[color=blue]
          >| 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[/color]
          fired[color=blue]
          >| from javascript.
          >| >
          >| >WebForm1.asp x
          >| >WebForm1.aspx. cs
          >| >
          >| >Check this link for more information:
          >| ><http://groups.google.com/groups?
          >| q=fire+an+event +javascript+yhh uang+click&hl
          >| >=en&lr=&ie=U TF-8&oe=UTF-8&selm=xsSGTcBU DHA.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,[/color]
          and[color=blue]
          >| confers no rights.
          >| >
          >| >
          >| >
          >| >--------------------
          >| >| Content-Class: urn:content-classes:message
          >| >| From: "Carlo Marchesoni" <carloma@trix.c om>
          >| >| Sender: "Carlo Marchesoni" <carloma@trix.c om>
          >| >| References: <019001c355fc$f 39147d0[/color]
          $a401280a@phx.g bl>[color=blue]
          >| ><Ch3eBalVDHA.2 240@cpmsftngxa0 6.phx.gbl>
          >| ><070a01c35665$ 572f0210$a60128 0a@phx.gbl>
          >| ><wPDIZtnVDHA.2 080@cpmsftngxa0 6.phx.gbl>
          >| >| Subject: RE: fire button event programmaticall y
          >| >| Date: Wed, 30 Jul 2003 03:52:08 -0700
          >| >| Lines: 150
          >| >| Message-ID: <0b5101c35688$9 f20be10$a301280 a@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: AcNWiJ8cNpvbvIv xSYCetBeJ8RXIdw ==
          >| >| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
          >| >| Path: cpmsftngxa06.ph x.gbl
          >| >| Xref: cpmsftngxa06.ph x.gbl
          >| microsoft.publi c.dotnet.framew ork.aspnet:1632 97
          >| >| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
          >| >| X-Tomcat-NG:[/color]
          microsoft.publi c.dotnet.framew ork.aspnet[color=blue]
          >| >|
          >| >| Sorry that I still don't get it - the article is
          >| >| interesting and I manage to do it all, but this[/color]
          just[color=blue]
          >| >| shows how to load values in the window.opener (or[/color]
          at[color=blue]
          >| >| least that's what I understood). But I still don't[/color]
          see[color=blue]
          >| >| how you can fire a code-behind event. At the end[/color]
          the[color=blue]
          >| >| 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[/color]
          for[color=blue]
          >| >| demonstration.
          >| >| >
          >| >| >I would also like to recommend one good article to
          >| you.
          >| >| >http://aspnet.4guysfromrolla.com/articles/030202-
          >| 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.c om>
          >| >| >| Sender: "Carlo Marchesoni" <carloma@trix.c om>
          >| >| >| References: <019001c355fc$f 39147d0
          >| $a401280a@phx.g bl>
          >| >| ><Ch3eBalVDHA.2 240@cpmsftngxa0 6.phx.gbl>
          >| >| >| Subject: RE: fire button event programmaticall y
          >| >| >| Date: Tue, 29 Jul 2003 23:39:35 -0700
          >| >| >| Lines: 88
          >| >| >| Message-ID: <070a01c35665$5 72f0210[/color]
          $a601280a@phx.g bl>[color=blue]
          >| >| >| 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: AcNWZVcsxsK24Tm kRNiO/8+BKduVCw==
          >| >| >| Newsgroups:[/color]
          microsoft.publi c.dotnet.framew ork.aspnet[color=blue]
          >| >| >| Path: cpmsftngxa06.ph x.gbl
          >| >| >| Xref: cpmsftngxa06.ph x.gbl
          >| >| microsoft.publi c.dotnet.framew ork.aspnet:1632 43
          >| >| >| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
          >| >| >| X-Tomcat-NG:
          >| microsoft.publi c.dotnet.framew ork.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.asp x:
          >| >| >| >There is a href and a Button1[server control][/color]
          on[color=blue]
          >| it.
          >| >| >| >
          >| >| >| ><a
          >| >| >| >href="javascri pt:test=window. open
          >| >| >| ('WebForm2.aspx ','test','width =300,height=1
          >| >| >| >88');test.focu s()">TEST</a>
          >| >| >| >
          >| >| >| >Button1'even t:
          >| >| >| >
          >| >| >| >private void Button1_Click(o bject sender,
          >| >| >| System.EventArg s e)
          >| >| >| >{
          >| >| >| >Response.Wri te ("Button1_Click ed~!");
          >| >| >| >}
          >| >| >| >
          >| >| >| >WebForm2.asp x:
          >| >| >| >
          >| >| >| >Drag a Literal control and a Button1 from the
          >| Toolbox
          >| >| to
          >| >| >| the page.
          >| >| >| >
          >| >| >| >private void Button1_Click(o bject sender,
          >| >| >| System.EventArg s e)
          >| >| >| >{
          >| >| >| >string strjscript = "<script
          >| >| language='javas cript'>alert
          >| >| >| ('fire');";
          >| >| >| > strjscript[/color]
          += "window.opener. Form1.Button1.c lick[color=blue]
          >| >| >| ();";
          >| >| >| >//Form1 is the default form name of[/color]
          WebForm1.aspx[color=blue]
          >| >| >| > strjscript += "</script" + ">";
          >| >| >| > Literal1.Text = strjscript;
          >| >| >| >}
          >| >| >| >
          >| >| >| >Please let me know if it meets your need.[/color]
          Thanks.[color=blue]
          >| >| >| >
          >| >| >| >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.c om>
          >| >| >| >| Sender: "Carlo Marchesoni" <carloma@trix.c om>
          >| >| >| >| Subject: fire button event programmaticall y
          >| >| >| >| Date: Tue, 29 Jul 2003 11:12:20 -0700
          >| >| >| >| Lines: 6
          >| >| >| >| Message-ID: <019001c355fc$f 39147d0
          >| $a401280a@phx.g bl>
          >| >| >| >| 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/PORCJM8aNh4SiaW EZ4VauLzTg==
          >| >| >| >| X-MimeOLE: Produced By Microsoft MimeOLE
          >| >| >| V5.50.4910.0300
          >| >| >| >| Newsgroups:
          >| microsoft.publi c.dotnet.framew ork.aspnet
          >| >| >| >| Path: cpmsftngxa06.ph x.gbl
          >| >| >| >| Xref: cpmsftngxa06.ph x.gbl
          >| >| >| microsoft.publi c.dotnet.framew ork.aspnet:1630 71
          >| >| >| >| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
          >| >| >| >| X-Tomcat-NG:
          >| >| microsoft.publi c.dotnet.framew ork.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[/color]
          in[color=blue]
          >| >| >| A.aspx
          >| >| >| >| to be fired. I guess the only way is using
          >| >| javascript -
          >| >| >|
          >| >| >| >| does anybody have a sample for this ?
          >| >| >| >| Thanks
          >| >| >| >|
          >| >| >| >
          >| >| >| >.
          >| >| >| >
          >| >| >|
          >| >| >
          >| >| >.
          >| >| >
          >| >|
          >|
          >
          >.
          >[/color]

          Comment

          • Lewis Wang [MSFT]

            #6
            RE: fire button event programmaticall y

            Hi Carlo,

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

            Best Regards,
            Lewis

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



            --------------------
            | Content-Class: urn:content-classes:message
            | From: "Carlo Marchesoni" <carloma@trix.c om>
            | Sender: "Carlo Marchesoni" <carloma@trix.c om>
            | References: <019001c355fc$f 39147d0$a401280 a@phx.gbl>
            <Ch3eBalVDHA.22 40@cpmsftngxa06 .phx.gbl>
            <070a01c35665$5 72f0210$a601280 a@phx.gbl>
            <wPDIZtnVDHA.20 80@cpmsftngxa06 .phx.gbl>
            <0b5101c35688$9 f20be10$a301280 a@phx.gbl>
            <dfcSQtqVDHA.22 76@cpmsftngxa06 .phx.gbl>
            <0eeb01c356bb$c 0767e50$a501280 a@phx.gbl>
            <s7Ez8WwVDHA.19 96@cpmsftngxa06 .phx.gbl>
            | Subject: RE: fire button event programmaticall y
            | Date: Thu, 31 Jul 2003 05:21:35 -0700
            | Lines: 303
            | Message-ID: <597701c3575e$4 8abb220$a001280 a@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: AcNXXkirlgpFq1o TQpG6ry/rcX8KHg==
            | Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
            | Path: cpmsftngxa06.ph x.gbl
            | Xref: cpmsftngxa06.ph x.gbl microsoft.publi c.dotnet.framew ork.aspnet:1637 17
            | NNTP-Posting-Host: TK2MSFTNGXA08 10.40.1.160
            | X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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.c om>
            | >| Sender: "Carlo Marchesoni" <carloma@trix.c om>
            | >| References: <019001c355fc$f 39147d0$a401280 a@phx.gbl>
            | ><Ch3eBalVDHA.2 240@cpmsftngxa0 6.phx.gbl>
            | ><070a01c35665$ 572f0210$a60128 0a@phx.gbl>
            | ><wPDIZtnVDHA.2 080@cpmsftngxa0 6.phx.gbl>
            | ><0b5101c35688$ 9f20be10$a30128 0a@phx.gbl>
            | ><dfcSQtqVDHA.2 276@cpmsftngxa0 6.phx.gbl>
            | >| Subject: RE: fire button event programmaticall y
            | >| Date: Wed, 30 Jul 2003 09:58:08 -0700
            | >| Lines: 236
            | >| Message-ID: <0eeb01c356bb$c 0767e50$a501280 a@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: AcNWu8B2jmMFBxs nR9CnHhmhAAxTNg ==
            | >| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
            | >| Path: cpmsftngxa06.ph x.gbl
            | >| Xref: cpmsftngxa06.ph x.gbl
            | microsoft.publi c.dotnet.framew ork.aspnet:1634 44
            | >| NNTP-Posting-Host: TK2MSFTNGXA13 10.40.1.165
            | >| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.aspnet
            | >|
            | >| Did you attach a file ? I just see 'here is a
            | sample...'
            | >| and then WebForm1.aspx and WebForm1.aspx.c s 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.asp x
            | >| >WebForm1.aspx. cs
            | >| >
            | >| >Check this link for more information:
            | >| ><http://groups.google.com/groups?
            | >| q=fire+an+event +javascript+yhh uang+click&hl
            | >| >=en&lr=&ie=U TF-8&oe=UTF-8&selm=xsSGTcBU DHA.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.c om>
            | >| >| Sender: "Carlo Marchesoni" <carloma@trix.c om>
            | >| >| References: <019001c355fc$f 39147d0
            | $a401280a@phx.g bl>
            | >| ><Ch3eBalVDHA.2 240@cpmsftngxa0 6.phx.gbl>
            | >| ><070a01c35665$ 572f0210$a60128 0a@phx.gbl>
            | >| ><wPDIZtnVDHA.2 080@cpmsftngxa0 6.phx.gbl>
            | >| >| Subject: RE: fire button event programmaticall y
            | >| >| Date: Wed, 30 Jul 2003 03:52:08 -0700
            | >| >| Lines: 150
            | >| >| Message-ID: <0b5101c35688$9 f20be10$a301280 a@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: AcNWiJ8cNpvbvIv xSYCetBeJ8RXIdw ==
            | >| >| Newsgroups: microsoft.publi c.dotnet.framew ork.aspnet
            | >| >| Path: cpmsftngxa06.ph x.gbl
            | >| >| Xref: cpmsftngxa06.ph x.gbl
            | >| microsoft.publi c.dotnet.framew ork.aspnet:1632 97
            | >| >| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
            | >| >| X-Tomcat-NG:
            | microsoft.publi c.dotnet.framew ork.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.
            | >| >| >http://aspnet.4guysfromrolla.com/articles/030202-
            | >| 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.c om>
            | >| >| >| Sender: "Carlo Marchesoni" <carloma@trix.c om>
            | >| >| >| References: <019001c355fc$f 39147d0
            | >| $a401280a@phx.g bl>
            | >| >| ><Ch3eBalVDHA.2 240@cpmsftngxa0 6.phx.gbl>
            | >| >| >| Subject: RE: fire button event programmaticall y
            | >| >| >| Date: Tue, 29 Jul 2003 23:39:35 -0700
            | >| >| >| Lines: 88
            | >| >| >| Message-ID: <070a01c35665$5 72f0210
            | $a601280a@phx.g bl>
            | >| >| >| 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: AcNWZVcsxsK24Tm kRNiO/8+BKduVCw==
            | >| >| >| Newsgroups:
            | microsoft.publi c.dotnet.framew ork.aspnet
            | >| >| >| Path: cpmsftngxa06.ph x.gbl
            | >| >| >| Xref: cpmsftngxa06.ph x.gbl
            | >| >| microsoft.publi c.dotnet.framew ork.aspnet:1632 43
            | >| >| >| NNTP-Posting-Host: TK2MSFTNGXA14 10.40.1.166
            | >| >| >| X-Tomcat-NG:
            | >| microsoft.publi c.dotnet.framew ork.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.asp x:
            | >| >| >| >There is a href and a Button1[server control]
            | on
            | >| it.
            | >| >| >| >
            | >| >| >| ><a
            | >| >| >| >href="javascri pt:test=window. open
            | >| >| >| ('WebForm2.aspx ','test','width =300,height=1
            | >| >| >| >88');test.focu s()">TEST</a>
            | >| >| >| >
            | >| >| >| >Button1'even t:
            | >| >| >| >
            | >| >| >| >private void Button1_Click(o bject sender,
            | >| >| >| System.EventArg s e)
            | >| >| >| >{
            | >| >| >| >Response.Wri te ("Button1_Click ed~!");
            | >| >| >| >}
            | >| >| >| >
            | >| >| >| >WebForm2.asp x:
            | >| >| >| >
            | >| >| >| >Drag a Literal control and a Button1 from the
            | >| Toolbox
            | >| >| to
            | >| >| >| the page.
            | >| >| >| >
            | >| >| >| >private void Button1_Click(o bject sender,
            | >| >| >| System.EventArg s e)
            | >| >| >| >{
            | >| >| >| >string strjscript = "<script
            | >| >| language='javas cript'>alert
            | >| >| >| ('fire');";
            | >| >| >| > strjscript
            | += "window.opener. Form1.Button1.c lick
            | >| >| >| ();";
            | >| >| >| >//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.c om>
            | >| >| >| >| Sender: "Carlo Marchesoni" <carloma@trix.c om>
            | >| >| >| >| Subject: fire button event programmaticall y
            | >| >| >| >| Date: Tue, 29 Jul 2003 11:12:20 -0700
            | >| >| >| >| Lines: 6
            | >| >| >| >| Message-ID: <019001c355fc$f 39147d0
            | >| $a401280a@phx.g bl>
            | >| >| >| >| 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/PORCJM8aNh4SiaW EZ4VauLzTg==
            | >| >| >| >| X-MimeOLE: Produced By Microsoft MimeOLE
            | >| >| >| V5.50.4910.0300
            | >| >| >| >| Newsgroups:
            | >| microsoft.publi c.dotnet.framew ork.aspnet
            | >| >| >| >| Path: cpmsftngxa06.ph x.gbl
            | >| >| >| >| Xref: cpmsftngxa06.ph x.gbl
            | >| >| >| microsoft.publi c.dotnet.framew ork.aspnet:1630 71
            | >| >| >| >| NNTP-Posting-Host: TK2MSFTNGXA12 10.40.1.164
            | >| >| >| >| X-Tomcat-NG:
            | >| >| microsoft.publi c.dotnet.framew ork.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
            | >| >| >| >|
            | >| >| >| >
            | >| >| >| >.
            | >| >| >| >
            | >| >| >|
            | >| >| >
            | >| >| >.
            | >| >| >
            | >| >|
            | >|
            | >
            | >.
            | >
            |

            Comment

            Working...