accessing html fields

Discussion in 'ASP .Net Building Controls' started by Jessica Weiner, Jul 5, 2006.

  1. I have an input field defined outside the <form> area. Its a simple html
    text input that is used to enter the number of hours.

    <input id="HoursField" name="hours" type="text" />

    I want to access this field from the server side (c# code). I tried these
    two methods to access the field but they dont work. Please help.

    String[] tempArray;
    tempArray = Request.Form.GetValues("hours");
    Response.Write (tempArray[0]);

    ---

    string val = Request.QueryString["hours"].ToString();
    Response.Write (val);


    Jessica
     
    Jessica Weiner, Jul 5, 2006
    #1
    1. Advertisements

  2. Jessica Weiner

    ValliM Guest

    Hi Jessica,

    To access the html control in the server side we have to include the
    property runat="server" in the input tag,

    <input id="HoursField" name="hours" runat="server" type="text"
    value="60:00"/>

    In the C# code you can access the HoursField by using the code

    Response.Write(HoursField.Value);

    Regards,

    Valli.

    www.syncfusion.com

    "Jessica Weiner" <> wrote in message
    news:YWCqg.126763$...
    >I have an input field defined outside the <form> area. Its a simple html
    >text input that is used to enter the number of hours.
    >
    > <input id="HoursField" name="hours" type="text" />
    >
    > I want to access this field from the server side (c# code). I tried these
    > two methods to access the field but they dont work. Please help.
    >
    > String[] tempArray;
    > tempArray = Request.Form.GetValues("hours");
    > Response.Write (tempArray[0]);
    >
    > ---
    >
    > string val = Request.QueryString["hours"].ToString();
    > Response.Write (val);
    >
    >
    > Jessica
    >
     
    ValliM, Jul 5, 2006
    #2
    1. Advertisements

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. call_me_anything
    Replies:
    4
    Views:
    571
    Pete Becker
    Sep 30, 2007
  2. Cyril.Liu
    Replies:
    0
    Views:
    528
    Cyril.Liu
    Dec 2, 2008
  3. Jessica Weiner

    accessing html fields

    Jessica Weiner, Jul 5, 2006, in forum: ASP .Net Web Services
    Replies:
    1
    Views:
    143
    Scott M.
    Jul 5, 2006
  4. middletree

    how to copy from fields to other fields

    middletree, Nov 5, 2003, in forum: ASP General
    Replies:
    1
    Views:
    225
    middletree
    Nov 5, 2003
  5. Jessica Weiner

    accessing html input fields

    Jessica Weiner, Jul 5, 2006, in forum: Javascript
    Replies:
    2
    Views:
    133
    marss
    Jul 5, 2006
Loading...

Share This Page