derived custom controls from Button or ImageButton

Discussion in 'ASP .Net Web Controls' started by jiatiejun, Jul 24, 2007.

  1. jiatiejun

    jiatiejun Guest

    I want write a custom controls (Button or ImageButton derived)

    and want set the "name" tag to my custom value

    use this.Attributes["name"] = "MyNameValue";

    or writer.AddAttribute(HtmlTextWriterAttribute.Name, "MyNameValue");

    asp.net add my "name" tag

    but itself name tag still exists

    result HTML code:

    <input type="submit" name="MyButton1" value="" id="MyButton1"
    name="MyNameValue" />
    ---------------------------^^^^^^^^^ Button base class
    +^^^^^^^^^^^ I add name tag
    -------------------------------------------------------------------+

    how to remove Button base class name tag ?


    thanks
     
    jiatiejun, Jul 24, 2007
    #1
    1. Advertising

  2. Try this:

    In the control's constructor, set this.Name = "MyNameValue";

    You may also want to explore using the TagPrefix attribute and the
    ToolboxData attribute.
    Here's more info on those:
    http://msdn2.microsoft.com/en-us/library/system.web.ui.tagprefixattribute(VS.71).aspx
    http://msdn2.microsoft.com/en-us/library/system.web.ui.toolboxdataattribute(VS.71).aspx

    --
    I hope this helps,
    Steve C. Orr,
    MCSD, MVP, CSM, ASPInsider
    http://SteveOrr.net


    "jiatiejun" <> wrote in message
    news:%...
    >I want write a custom controls (Button or ImageButton derived)
    >
    > and want set the "name" tag to my custom value
    >
    > use this.Attributes["name"] = "MyNameValue";
    >
    > or writer.AddAttribute(HtmlTextWriterAttribute.Name, "MyNameValue");
    >
    > asp.net add my "name" tag
    >
    > but itself name tag still exists
    >
    > result HTML code:
    >
    > <input type="submit" name="MyButton1" value="" id="MyButton1"
    > name="MyNameValue" />
    > ---------------------------^^^^^^^^^ Button base class +^^^^^^^^^^^ I add
    > name tag
    > -------------------------------------------------------------------+
    >
    > how to remove Button base class name tag ?
    >
    >
    > thanks
    >
    >
    >
     
    Steve C. Orr [MCSD, MVP, CSM, ASP Insider], Jul 25, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    440
    Alf P. Steinbach
    May 23, 2007
  2. Replies:
    1
    Views:
    425
    myork
    May 23, 2007
  3. Replies:
    1
    Views:
    412
    Victor Bazarov
    May 23, 2007
  4. rodchar
    Replies:
    0
    Views:
    409
    rodchar
    Nov 26, 2007
  5. David
    Replies:
    3
    Views:
    434
    Grizlyk
    Jan 29, 2008
Loading...

Share This Page