Input fields are renamed with runat="server", how do I change it

Discussion in 'ASP .Net Web Controls' started by jamessmb, Jan 14, 2006.

  1. jamessmb

    jamessmb Guest

    Hello,

    I have a webform which needs to post to PayPal. One of the elements is a
    hidden field which I am populating with a value from the URL. In order to do
    this, I have to use runat="server'. But when I do, ASP.NET will rename the
    field. The field needs to be named "custom" so PayPal will know what to do
    with it.

    How can I prevent this, or what can I do?
    Thanks,
    James
     
    jamessmb, Jan 14, 2006
    #1
    1. Advertising

  2. jamessmb

    Axel Dahmen Guest

    Can't reproduce this. Which version of .NET are you using?

    Axel Dahmen

    ---------------
    "jamessmb" <> schrieb im Newsbeitrag
    news:D...
    > Hello,
    >
    > I have a webform which needs to post to PayPal. One of the elements is a
    > hidden field which I am populating with a value from the URL. In order to

    do
    > this, I have to use runat="server'. But when I do, ASP.NET will rename the
    > field. The field needs to be named "custom" so PayPal will know what to do
    > with it.
    >
    > How can I prevent this, or what can I do?
    > Thanks,
    > James
     
    Axel Dahmen, Jan 16, 2006
    #2
    1. Advertising

  3. jamessmb

    jamessmb Guest

    Re: Input fields are renamed with runat="server", how do I change

    Hi,

    I'm using version 2

    create an input field like this:
    <input type="hidden" id="custom" name="custom" value="" runat="server" />

    What is rendered is this:

    <input name="ctl00$ctl00$SiteContentPlaceHolder$CenterColumn$custom"
    type="hidden" id="ctl00_ctl00_SiteContentPlaceHolder_CenterColumn_custom" />

    I actually did find a workaround with Javascript, since the "custom"
    variable is passed in the query string to this page:

    var uName = document.location.search;
    var uNameArr = uName.split("=");
    document.getElementById('custom').value = uNameArr[1];

    However, I still would like to know how to deal with this. It seems to me
    there should be a way to keep the name.

    Thanks,
    James
    "Axel Dahmen" wrote:

    > Can't reproduce this. Which version of .NET are you using?
    >
    > Axel Dahmen
    >
    > ---------------
    > "jamessmb" <> schrieb im Newsbeitrag
    > news:D...
    > > Hello,
    > >
    > > I have a webform which needs to post to PayPal. One of the elements is a
    > > hidden field which I am populating with a value from the URL. In order to

    > do
    > > this, I have to use runat="server'. But when I do, ASP.NET will rename the
    > > field. The field needs to be named "custom" so PayPal will know what to do
    > > with it.
    > >
    > > How can I prevent this, or what can I do?
    > > Thanks,
    > > James

    >
    >
    >
     
    jamessmb, Jan 16, 2006
    #3
  4. Re: Input fields are renamed with runat="server", how do I change

    You could subclass HtmlInputHidden (or whatever that thing is called;
    there's 2 similarly-named ones, and I can never remember which is which) and
    override ClientID and UniqueID, but that behavior is otherwise by design, as
    it needs to prepend the control tree before the name/ID so that two
    identically-named fields (gets common with user controls) don't "collide"
     
    Keith Patrick, Jan 17, 2006
    #4
    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. Mark Sandfox
    Replies:
    1
    Views:
    1,207
    Jason DeFontes
    May 11, 2004
  2. =?Utf-8?B?U2liQW5kZWxh?=

    <INPUT type="file" runat="server" - attach to email

    =?Utf-8?B?U2liQW5kZWxh?=, Jul 31, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    848
    Lau Lei Cheong
    Aug 2, 2004
  3. yoshra
    Replies:
    0
    Views:
    599
    yoshra
    May 8, 2005
  4. =?Utf-8?B?SmFpbWUgU3R1YXJkbw==?=

    Difference between <asp:textbox> and <input runat="server">

    =?Utf-8?B?SmFpbWUgU3R1YXJkbw==?=, Oct 7, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    7,555
    Mr Newbie
    Oct 7, 2005
  5. Chris
    Replies:
    4
    Views:
    1,292
    Chris
    Jun 11, 2007
Loading...

Share This Page