HTML Control & Code Behind Module!


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 3 of 3

Thread: HTML Control & Code Behind Module!

Hybrid View

  1. #1
    hari Guest

    HTML Control & Code Behind Module!


    Hi,
    I am using a hidden input type in my web form. But when I try to access
    that variable in code behind module, it seems the module doesnt know about
    the variable at all.

    The code is like this

    In WebForm:
    <input type="hidden" id="username">
    I am setting a value here on "Onclick" event of a HTML button and then submitting
    it to the server.

    In CodeModule(C#):
    Label1.Text = username.Text

    This gives an error. Is it wrong to access HTML control in code behind module???
    Could any one please help me!!!

    Thanks,
    Hari

  2. #2
    Constance J. Petersen Guest

    Re: HTML Control & Code Behind Module!

    Hi Hari,

    "hari" <v_hari@indya.com> wrote in message news:3ca9a513$1@10.1.10.29...
    > I am using a hidden input type in my web form. But when I try to access
    > that variable in code behind module, it seems the module doesnt know about
    > the variable at all.

    ....
    > This gives an error. Is it wrong to access HTML control in code behind

    module???
    > Could any one please help me!!!


    To access the HTML control via code behind, you'll need add runat="server" to
    the hidden input:

    <input type="hidden" id="username" runat="server">

    Also, on the server, I believe you will have to access username.value (not
    username.text).
    --
    Constance Petersen, DevX newsgroup section leader
    SoftMedia Artisans, Inc.
    http://www.smartisans.com
    For useful, usable software and Web sites
    Featured Web design: http://www.keweenawnow.com/
    --
    Please reply in the newsgroup so everyone can benefit




  3. #3
    Phil Weber Guest

    Re: HTML Control & Code Behind Module!

    > Label1.Text = username.Text

    Hari: Alternatively, you can simply retrieve the hidden input field's value
    from the Request object, as you would in standard ASP:

    <input type="hidden" name="username">

    // on server:
    Label1.Text = Request("username")

    ---
    Phil Weber



Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center