Accessing input fields declared outside the form

Discussion in 'ASP .Net' 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. Advertising

  2. Jessica Weiner

    Guest

    1. some people consider it bad form to post to more than one newgroup
    :)

    2. why is this input field outside of the form?

    cheers

    neil


    Jessica Weiner wrote:
    > 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
    , Jul 5, 2006
    #2
    1. Advertising

  3. Jessica Weiner

    Guest

    Jessica Weiner wrote:
    > 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" />
    >

    don't declare it outside the form tag.
    use
    <input id="hoursfield" name="hours" type="text" runat="server">

    and then use it in script tags
    like
    string hours="";
    hours=hoursfield.text;
    , Jul 5, 2006
    #3
    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. JohnZing

    declared or not declared ?

    JohnZing, Feb 5, 2006, in forum: ASP .Net
    Replies:
    3
    Views:
    1,570
    Jon Paal
    Feb 5, 2006
  2. Cplusplus
    Replies:
    1
    Views:
    323
    John Harrison
    Nov 9, 2004
  3. Krzysztof Poc

    outside type, outside function

    Krzysztof Poc, Feb 3, 2012, in forum: C++
    Replies:
    1
    Views:
    274
    Victor Bazarov
    Feb 7, 2012
  4. Otto Wyss

    Posting input fields outside of a form

    Otto Wyss, Mar 26, 2007, in forum: Javascript
    Replies:
    5
    Views:
    102
  5. Replies:
    23
    Views:
    478
    Tim Streater
    Dec 18, 2013
Loading...

Share This Page