control id and name for postback mechanism

Ask a Question related to ASP.NET Building Controls, Design and Development.

  1. #1

    Default control id and name for postback mechanism

    Hi,

    This may be a dumb question, but why is it necessary for a control's id and
    name attribute to coincide in order for the postback mechanism to work?

    Given that it appears to be necessary, why are they not wired to be the same
    value in a base class like control or webcontrol?

    Thanks
    Martin


    Martin Guest

  2. Similar Questions and Discussions

    1. why does my control retain its value after postback
      i am not implementing any state mechanisms or IPostBackEventHandler in my control, but when my asp.net page accesses the control, the data that was...
    2. help with postback-less calendar control.
      hi, I need to create a Calendar control that does not do postback when a date is selected...any ideas on how to do this thanks in advance...
    3. Did my control caused the postback
      You want to know it on Page or in the control itself? If your control implements IPostBackEventHandler, you could override RaisePostBackEvent on...
    4. control not found on postback
      Hi, i am trying to analyze data submitted in a form but the problem is that when i try to create the controls in code (which is what i want to...
    5. Which control had focus before postback?
      Hi, Is it possible to retrieve the control that had the focus when the page was posted back? Because the focus is lost when a postback occurs...
  3. #2

    Default Re: control id and name for postback mechanism

    Remember that the value in name attribute matches control's UniqueID, that
    is unique ID value so that control can be distinguished from the other
    controls, e.g to know which control is in question. UniqueID contains path
    of IDs with predefined separators revealing the control path in which the
    current control is located in.

    Page.FindControl method on the other hand is able to locate the control (and
    return reference to it) when it is given a unique id. In other words it
    doesn't need to loop through all the controls, evaluating which one's ID
    would match. And this is used with postback processing, and is one reason
    why name must match UniqueID. It not just finds the control, superfast, but
    also causes child control hierarchies to be created (ensures that control
    receiving postback is there).

    --
    Teemu Keiski
    ASP.NET MVP, AspInsider
    Finland, EU
    [url]http://blogs.aspadvice.com/joteke[/url]

    "Martin" <x@y.z> wrote in message
    news:%23ZFMd%23pwGHA.5068@TK2MSFTNGP02.phx.gbl...
    > Hi,
    >
    > This may be a dumb question, but why is it necessary for a control's id
    > and name attribute to coincide in order for the postback mechanism to
    > work?
    >
    > Given that it appears to be necessary, why are they not wired to be the
    > same value in a base class like control or webcontrol?
    >
    > Thanks
    > Martin
    >
    >

    Teemu Keiski 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