Html Form Help!!!

Discussion in 'ASP .Net' started by Roshawn Dawson, May 9, 2006.

  1. Hi,

    I have an .aspx page that contains an html form. Below is the code used for the form:


    <form id="Shoes" method="post" runat="server">
    <label for="q">Search:</label><br />
    <asp:textbox id="q" maxlength="100" runat="server"/><br />
    <label for="sz">Shoe Size (US):</label><br />
    <asp:dropdownlist id="sz" runat="server"/><br /> <!-- this control is populated programmatically -->
    <label for="tp">Type:</label><br />
    <asp:dropdownlist id="tp" runat="server">
    <asp:listitem value="24">Any</asp:listitem>
    <asp:listitem value="2293">Athletic</asp:listitem>
    <asp:listitem value="31920">Athletic-Inspired</asp:listitem>
    </asp:dropdownlist><br />
    <label for="cd">Condition:</label><br />
    <asp:dropdownlist id="cd" runat="server">
    <asp:listitem value="24">Any</asp:listitem>
    <asp:listitem value="31919">New</asp:listitem>
    </asp:dropdownlist><br />
    <input type="submit" value="Search"/>
    </form>


    All is good here.

    But should I specify any form variables and perform a postback, I can't access any of the form
    controls using either the Request.Form collection or using Request.Querystring collection.

    I have no idea why this is happening. Can anyone help this newbie?

    Thanks,
    Roshawn
    Roshawn Dawson, May 9, 2006
    #1
    1. Advertising

  2. I don't see anything particularly wrong with your form ASPX tag code.
    You have not shown how you expect to access these values on a postback.

    The typicaly pattern is:

    Page_Load( ....)
    {
    if(IsPostBack)
    {
    //get values here

    }

    Peter
    --
    Co-founder, Eggheadcafe.com developer portal:
    http://www.eggheadcafe.com
    UnBlog:
    http://petesbloggerama.blogspot.com




    "Roshawn Dawson" wrote:

    > Hi,
    >
    > I have an .aspx page that contains an html form. Below is the code used for the form:
    >
    >
    > <form id="Shoes" method="post" runat="server">
    > <label for="q">Search:</label><br />
    > <asp:textbox id="q" maxlength="100" runat="server"/><br />
    > <label for="sz">Shoe Size (US):</label><br />
    > <asp:dropdownlist id="sz" runat="server"/><br /> <!-- this control is populated programmatically -->
    > <label for="tp">Type:</label><br />
    > <asp:dropdownlist id="tp" runat="server">
    > <asp:listitem value="24">Any</asp:listitem>
    > <asp:listitem value="2293">Athletic</asp:listitem>
    > <asp:listitem value="31920">Athletic-Inspired</asp:listitem>
    > </asp:dropdownlist><br />
    > <label for="cd">Condition:</label><br />
    > <asp:dropdownlist id="cd" runat="server">
    > <asp:listitem value="24">Any</asp:listitem>
    > <asp:listitem value="31919">New</asp:listitem>
    > </asp:dropdownlist><br />
    > <input type="submit" value="Search"/>
    > </form>
    >
    >
    > All is good here.
    >
    > But should I specify any form variables and perform a postback, I can't access any of the form
    > controls using either the Request.Form collection or using Request.Querystring collection.
    >
    > I have no idea why this is happening. Can anyone help this newbie?
    >
    > Thanks,
    > Roshawn
    >
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, May 9, 2006
    #2
    1. Advertising

  3. Hmm...

    Your suggestion is simple enough. I though that you don't always have to check if the page was
    posted back. I thought that I could slap some code onto the page and simply use the Request object.
    Seems I was wrong.

    Thanks for the tip, Peter. :)

    Peter Bromberg [C# MVP] wrote:
    > I don't see anything particularly wrong with your form ASPX tag code.
    > You have not shown how you expect to access these values on a postback.
    >
    > The typicaly pattern is:
    >
    > Page_Load( ....)
    > {
    > if(IsPostBack)
    > {
    > //get values here
    >
    > }
    >
    > Peter
    Roshawn Dawson, May 9, 2006
    #3
  4. I appreciate your suggestion, but unfortunately nothing works. I still cannot use the Request.Form
    collection or the Request.QueryString collection.

    Thanks anyway,
    Roshawn
    Roshawn Dawson, May 9, 2006
    #4
  5. If you want to post a "Short but complete" code sample, sombody will review
    it. How about your AutoEventWireup directive, how is that set? Have you set a
    breakpont on the code line that you expect to see executed, to see if it is
    actually reached? Have you tried using the locals window to look at values?
    Peter

    --
    Co-founder, Eggheadcafe.com developer portal:
    http://www.eggheadcafe.com
    UnBlog:
    http://petesbloggerama.blogspot.com




    "Roshawn Dawson" wrote:

    > I appreciate your suggestion, but unfortunately nothing works. I still cannot use the Request.Form
    > collection or the Request.QueryString collection.
    >
    > Thanks anyway,
    > Roshawn
    >
    =?Utf-8?B?UGV0ZXIgQnJvbWJlcmcgW0MjIE1WUF0=?=, May 9, 2006
    #5
  6. Hi, Roshawn.

    What you are looking for is the Request.Params collection.

    See example usage at :
    http://www.informit.com/articles/article.asp?p=28502&seqNum=4&rl=1

    http://www.hanselman.com/blog/ASPNE...ringFormsVsRequestindexAndDoubleDecoding.aspx





    Juan T. Llibre, asp.net MVP
    aspnetfaq.com : http://www.aspnetfaq.com/
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "Roshawn Dawson" <> wrote in message
    news:...
    >I appreciate your suggestion, but unfortunately nothing works. I still cannot use the Request.Form
    >collection or the Request.QueryString collection.
    >
    > Thanks anyway,
    > Roshawn
    Juan T. Llibre, May 9, 2006
    #6
  7. Hi Juan,

    I've done some more testing, and what I found is strange. Both the Request.Params and the
    Request.QueryString collections are empty.

    I have no idea why this is. Could setting the EnableViewState property to true have an effect on
    these collections?

    Thanks,
    Roshawn

    Juan T. Llibre wrote:
    > Hi, Roshawn.
    >
    > What you are looking for is the Request.Params collection.
    >
    > See example usage at :
    > http://www.informit.com/articles/article.asp?p=28502&seqNum=4&rl=1
    >
    > http://www.hanselman.com/blog/ASPNE...ringFormsVsRequestindexAndDoubleDecoding.aspx
    >
    >
    >
    >
    >
    > Juan T. Llibre, asp.net MVP
    > aspnetfaq.com : http://www.aspnetfaq.com/
    > asp.net faq : http://asp.net.do/faq/
    > foros de asp.net, en español : http://asp.net.do/foros/
    Roshawn Dawson, May 10, 2006
    #7
  8. Never mind; I figured it out. Silly me, I didn't supply a name attribute for any of the form's
    controls. That's why I couldn't get any data.

    And to think that I need a hairpiece for nothing (I pulled all of it out). :-(

    Thanks gang,
    Roshawn
    Roshawn Dawson, May 10, 2006
    #8
  9. heh, heh...
    Been there, done that!

    I bet it felt good to finally figure it out!

    :)



    Juan T. Llibre, asp.net MVP
    aspnetfaq.com : http://www.aspnetfaq.com/
    asp.net faq : http://asp.net.do/faq/
    foros de asp.net, en español : http://asp.net.do/foros/
    ===================================
    "Roshawn Dawson" <> wrote in message
    news:%23WISox%...
    > Never mind; I figured it out. Silly me, I didn't supply a name attribute for any of the form's
    > controls. That's why I couldn't get any data.
    >
    > And to think that I need a hairpiece for nothing (I pulled all of it out). :-(
    >
    > Thanks gang,
    > Roshawn
    Juan T. Llibre, May 10, 2006
    #9
    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. Li Zhang
    Replies:
    4
    Views:
    6,042
    softip
    Feb 27, 2009
  2. Mark
    Replies:
    2
    Views:
    6,056
  3. Matt
    Replies:
    8
    Views:
    141,970
    zeeshanakhter2009
    May 26, 2012
  4. Matt
    Replies:
    0
    Views:
    678
  5. rob c
    Replies:
    4
    Views:
    309
    McKirahan
    Dec 30, 2005
Loading...

Share This Page