click button

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

    #1

    click button

    In a web form, I want the user clicks on one button and this button will
    trigger another button/link which will open a new browser window? How to do
    that? Is there any method like
    Button.performc lick?

    Thanks
  • Scott M.

    #2
    Re: click button

    Opening another browser window is not something you can do from server-side
    code. Only the client can control the client. You have 2 questions here so
    let me answer them individually.

    1. How to call the click event of a button from the click event of another
    button: This is accomplished by simply placing a call to the click event
    handler of the second button in the first:

    Sub Button1_Click() Handles Button1.Click
    'Call the click event handler of button2
    Button2_Click()
    End Sub

    Sub Button2_Click() Handles Button2.Click
    'Button2's click event code here
    End Sub

    2. How to open a new browser window. As stated, only client-side code
    (JavaScript) can do this, so you either have to embed a client-side script
    and add a client-side event handler to a button
    (onClick="windo w.open('fileToO pen')) or send this code to the client-side
    control from the server side:

    Page_Load()
    Button2.Attribu tes.Add("onClic k","window.open ('fileToOpen')" )
    End Sub






    "yfng" <yfng@discussio ns.microsoft.co m> wrote in message
    news:2630A216-F0F1-4B67-B24E-A96E06462B0A@mi crosoft.com...[color=blue]
    > In a web form, I want the user clicks on one button and this button will
    > trigger another button/link which will open a new browser window? How to
    > do
    > that? Is there any method like
    > Button.performc lick?
    >
    > Thanks[/color]


    Comment

    • yfng

      #3
      Re: click button

      Thanks.
      But the problem is that... I want to ensure that some server scripts will
      run before another browser window opens... For the
      button.attribut e.add("onclick" , "javascript:win dow.open")... It seems that it
      cannot gurantee this ...

      "Scott M." wrote:
      [color=blue]
      > Opening another browser window is not something you can do from server-side
      > code. Only the client can control the client. You have 2 questions here so
      > let me answer them individually.
      >
      > 1. How to call the click event of a button from the click event of another
      > button: This is accomplished by simply placing a call to the click event
      > handler of the second button in the first:
      >
      > Sub Button1_Click() Handles Button1.Click
      > 'Call the click event handler of button2
      > Button2_Click()
      > End Sub
      >
      > Sub Button2_Click() Handles Button2.Click
      > 'Button2's click event code here
      > End Sub
      >
      > 2. How to open a new browser window. As stated, only client-side code
      > (JavaScript) can do this, so you either have to embed a client-side script
      > and add a client-side event handler to a button
      > (onClick="windo w.open('fileToO pen')) or send this code to the client-side
      > control from the server side:
      >
      > Page_Load()
      > Button2.Attribu tes.Add("onClic k","window.open ('fileToOpen')" )
      > End Sub
      >
      >
      >
      >
      >
      >
      > "yfng" <yfng@discussio ns.microsoft.co m> wrote in message
      > news:2630A216-F0F1-4B67-B24E-A96E06462B0A@mi crosoft.com...[color=green]
      > > In a web form, I want the user clicks on one button and this button will
      > > trigger another button/link which will open a new browser window? How to
      > > do
      > > that? Is there any method like
      > > Button.performc lick?
      > >
      > > Thanks[/color]
      >
      >
      >[/color]

      Comment

      • Scott M.

        #4
        Re: click button

        How about having one .aspx page run your server code and when they are done,
        simply use response.redire ct or server.transfer to call another server page
        that includes the button with the onClick event handler?


        "yfng" <yfng@discussio ns.microsoft.co m> wrote in message
        news:E3B41427-492F-4FC3-88FF-39EE1D39324C@mi crosoft.com...[color=blue]
        > Thanks.
        > But the problem is that... I want to ensure that some server scripts will
        > run before another browser window opens... For the
        > button.attribut e.add("onclick" , "javascript:win dow.open")... It seems that
        > it
        > cannot gurantee this ...
        >
        > "Scott M." wrote:
        >[color=green]
        >> Opening another browser window is not something you can do from
        >> server-side
        >> code. Only the client can control the client. You have 2 questions here
        >> so
        >> let me answer them individually.
        >>
        >> 1. How to call the click event of a button from the click event of
        >> another
        >> button: This is accomplished by simply placing a call to the click event
        >> handler of the second button in the first:
        >>
        >> Sub Button1_Click() Handles Button1.Click
        >> 'Call the click event handler of button2
        >> Button2_Click()
        >> End Sub
        >>
        >> Sub Button2_Click() Handles Button2.Click
        >> 'Button2's click event code here
        >> End Sub
        >>
        >> 2. How to open a new browser window. As stated, only client-side code
        >> (JavaScript) can do this, so you either have to embed a client-side
        >> script
        >> and add a client-side event handler to a button
        >> (onClick="windo w.open('fileToO pen')) or send this code to the client-side
        >> control from the server side:
        >>
        >> Page_Load()
        >> Button2.Attribu tes.Add("onClic k","window.open ('fileToOpen')" )
        >> End Sub
        >>
        >>
        >>
        >>
        >>
        >>
        >> "yfng" <yfng@discussio ns.microsoft.co m> wrote in message
        >> news:2630A216-F0F1-4B67-B24E-A96E06462B0A@mi crosoft.com...[color=darkred]
        >> > In a web form, I want the user clicks on one button and this button
        >> > will
        >> > trigger another button/link which will open a new browser window? How
        >> > to
        >> > do
        >> > that? Is there any method like
        >> > Button.performc lick?
        >> >
        >> > Thanks[/color]
        >>
        >>
        >>[/color][/color]


        Comment

        • yfng

          #5
          Re: click button

          Thanks.

          "Scott M." wrote:
          [color=blue]
          > How about having one .aspx page run your server code and when they are done,
          > simply use response.redire ct or server.transfer to call another server page
          > that includes the button with the onClick event handler?
          >
          >
          > "yfng" <yfng@discussio ns.microsoft.co m> wrote in message
          > news:E3B41427-492F-4FC3-88FF-39EE1D39324C@mi crosoft.com...[color=green]
          > > Thanks.
          > > But the problem is that... I want to ensure that some server scripts will
          > > run before another browser window opens... For the
          > > button.attribut e.add("onclick" , "javascript:win dow.open")... It seems that
          > > it
          > > cannot gurantee this ...
          > >
          > > "Scott M." wrote:
          > >[color=darkred]
          > >> Opening another browser window is not something you can do from
          > >> server-side
          > >> code. Only the client can control the client. You have 2 questions here
          > >> so
          > >> let me answer them individually.
          > >>
          > >> 1. How to call the click event of a button from the click event of
          > >> another
          > >> button: This is accomplished by simply placing a call to the click event
          > >> handler of the second button in the first:
          > >>
          > >> Sub Button1_Click() Handles Button1.Click
          > >> 'Call the click event handler of button2
          > >> Button2_Click()
          > >> End Sub
          > >>
          > >> Sub Button2_Click() Handles Button2.Click
          > >> 'Button2's click event code here
          > >> End Sub
          > >>
          > >> 2. How to open a new browser window. As stated, only client-side code
          > >> (JavaScript) can do this, so you either have to embed a client-side
          > >> script
          > >> and add a client-side event handler to a button
          > >> (onClick="windo w.open('fileToO pen')) or send this code to the client-side
          > >> control from the server side:
          > >>
          > >> Page_Load()
          > >> Button2.Attribu tes.Add("onClic k","window.open ('fileToOpen')" )
          > >> End Sub
          > >>
          > >>
          > >>
          > >>
          > >>
          > >>
          > >> "yfng" <yfng@discussio ns.microsoft.co m> wrote in message
          > >> news:2630A216-F0F1-4B67-B24E-A96E06462B0A@mi crosoft.com...
          > >> > In a web form, I want the user clicks on one button and this button
          > >> > will
          > >> > trigger another button/link which will open a new browser window? How
          > >> > to
          > >> > do
          > >> > that? Is there any method like
          > >> > Button.performc lick?
          > >> >
          > >> > Thanks
          > >>
          > >>
          > >>[/color][/color]
          >
          >
          >[/color]

          Comment

          Working...