Dynamically Hyperlink and Event Handler for the Hyperlink ?

Ask a Question related to ASP.NET Data Grid Control, Design and Development.

  1. #1

    Default Dynamically Hyperlink and Event Handler for the Hyperlink ?

    Hi,

    I´m creating an Hyperlink dynamically for my DataGrid:


    HyperLink hl = new HyperLink();
    hl.Text = "MyLink";
    hl.NavigateUrl = "#";
    e.Item.Cells[3].Controls.Add(hl);

    When the user clicks that HyperLink, instead of sending to an specified URL
    in the
    NavigateUrl, example : hl.NavigateUrl = [url]http://www.site.com;[/url] I want to
    'catch' the
    click event and call a Method instead

    private void MyMethod()
    {
    // do something here!
    }

    Any ideas for that?
    Ken.



    Ken Guest

  2. Similar Questions and Discussions

    1. How do I get the Clicked Event on Hyperlink to execute a Command?
      I have a ButtonColumn as a link. When the user clicks on it, I want to execute a command to query a database and display data in another grid. I...
    2. how to change the colour of hyperlink used in datagrid in vb.net on CLICK EVENT?
      (Type your message here) please send the coding in VB.NET or HTML for changing the colour of HYPERLINK used in DATAGRID(from COLUMNS property of...
    3. Hyperlink Column Event Handler...
      Hi, I have a hyperlink column for my datagrid. I do not want to use the query string and expose the "app_id" in that. Instead I would like to...
    4. DataGrid's UpdateCommand event handler and CancelCommand handler problem
      I am having the same problem: the wrong event handler is being fired when column headings and page changes are clicked. I am using the datagrid...
    5. Assign Javascript event handler function dynamically to a Flash object event?
      I have a Flash player object embedded in one of my web pages. I want to assign code to the OnReadyStateChange event for the object. Every...
  3. #2

    Default Re: Dynamically Hyperlink and Event Handler for the Hyperlink ?

    you need to add this line when you generate your control
    hl.Click +=new EventHandler(MyMethod);

    your mymethod must be declared like this to match the click event delegate

    private void MyMethod(object sender, System.EventArgs e)

    "Ken" <ken_awamura@hotmail.com> wrote in message
    news:#xcJlemYDHA.2204@TK2MSFTNGP12.phx.gbl...
    > Hi,
    >
    > I´m creating an Hyperlink dynamically for my DataGrid:
    >
    >
    > HyperLink hl = new HyperLink();
    > hl.Text = "MyLink";
    > hl.NavigateUrl = "#";
    > e.Item.Cells[3].Controls.Add(hl);
    >
    > When the user clicks that HyperLink, instead of sending to an specified
    URL
    > in the
    > NavigateUrl, example : hl.NavigateUrl = [url]http://www.site.com;[/url] I want to
    > 'catch' the
    > click event and call a Method instead
    >
    > private void MyMethod()
    > {
    > // do something here!
    > }
    >
    > Any ideas for that?
    > Ken.
    >
    >
    >

    Alvin Bruney 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