Professional Web Applications Themes

Overwriting the "href='javascript:__doPostBack........" in a LinkButton - ASP.NET Building Controls

I'm building a custom LinkButton control that will confirm a deletion before processing it. I've tried a few different things, some partially successful, and I did find someone who had a script that does this (though I didn't like the implementation so I'm still trying). I'm wondering if there is any way to inherit the System.Web.UI.WebControls.LinkButton class, and then overwrite how it renders the "href='javascript :__doPostBack('....','')" attribute. I figure that I could register a custom javascript with the page, and then have the href point to my script, which then runs instead. I can't figure out how to do this. ...

  1. #1

    Default Overwriting the "href='javascript:__doPostBack........" in a LinkButton

    I'm building a custom LinkButton control that will confirm a deletion
    before processing it.

    I've tried a few different things, some partially successful, and I
    did find someone who had a script that does this (though I didn't like
    the implementation so I'm still trying).

    I'm wondering if there is any way to inherit the
    System.Web.UI.WebControls.LinkButton class, and then overwrite how it
    renders the "href='javascript:__doPostBack('....','')" attribute.

    I figure that I could register a custom javascript with the page, and
    then have the href point to my script, which then runs instead.

    I can't figure out how to do this. Is it possible? If so, how?

    Thanks,
    Jeffrey
    Jeffrey Guest

  2. #2

    Default Re: Overwriting the "href='javascript:__doPostBack........" in a LinkButton

    Hi,

    Register your client script function in the OnPreRender event of
    your control. In the Render event, get the html that is to be rendered to
    the client, from the HtmlTextWriter object that is passed to the method,
    modify this html so that the href points to your function and then render
    the modified html to the client.

    Regards














    "Jeffrey" <jeffkretzhotmail.com> wrote in message
    news:2264ae0.0402121418.6b70bdb9posting.google.co m...
    > I'm building a custom LinkButton control that will confirm a deletion
    > before processing it.
    >
    > I've tried a few different things, some partially successful, and I
    > did find someone who had a script that does this (though I didn't like
    > the implementation so I'm still trying).
    >
    > I'm wondering if there is any way to inherit the
    > System.Web.UI.WebControls.LinkButton class, and then overwrite how it
    > renders the "href='javascript:__doPostBack('....','')" attribute.
    >
    > I figure that I could register a custom javascript with the page, and
    > then have the href point to my script, which then runs instead.
    >
    > I can't figure out how to do this. Is it possible? If so, how?
    >
    > Thanks,
    > Jeffrey

    JohnnyV Guest

  3. #3

    Default Re: Overwriting the "href='javascript:__doPostBack........" in aLinkButton

    Jeffrey wrote:
    > I'm building a custom LinkButton control that will confirm a deletion
    > before processing it.
    >
    > I've tried a few different things, some partially successful, and I
    > did find someone who had a script that does this (though I didn't like
    > the implementation so I'm still trying).
    LinkButton.Attributes.Add("onclick", "return confirm('Are you sure?');")

    --
    Anthony Williams
    [url]http://www.bigtone.net[/url]
    Anthony Williams Guest

Similar Threads

  1. "Page" and "Rect" props of the Field prop in Javascript API
    By ArtIn_Act@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 8
    Last Post: March 19th, 05:35 PM
  2. <a href="#" onclick="MyFolderProfile('<%=sFolder%>') en NET?
    By Danny Patricia in forum ASP.NET General
    Replies: 0
    Last Post: July 16th, 08:47 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not 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