ASP.Net 2.0 request.form not working with master page

Posted on 2006-04-19
Last Modified: 2010-05-18
I have a form containing a text box where users can type in a keyword and search a database.  Everything is working fine until I incorporate it into a content page with a master page.  Once I do that, Request.Form("Keyword") does not seem to be working.  I'm using ASP.Net 2.0, Visual Web Developer, and VB.  Is there something I should/could be using other than request.form to capture the value in the keyword field?  Thanks for the help.
My content page contains the following:

<%@ page language="VB" masterpagefile="~/Site.master" codeFile="Default.aspx.vb" Inherits="_Default"%>

<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" Runat="server">
My master page contains:

<asp:ContentPlaceHolder ID="mainContent" runat="server" />

Question by:drees727
    LVL 20

    Accepted Solution

    LVL 33

    Expert Comment

    Using Request.Form isn't really a good approach.  I don't see this textbox you are using on your master page, but assuming it is there, you could try this.

    masterValue = Page.Master.myTextBox.Text

    Author Comment

    The text box is on the content page and not the master page.  That seems to be the root of the problem.  I'm using the following on the content page:

    <asp:TextBox ID="Keyword" runat="server"></asp:TextBox>

    LVL 33

    Assisted Solution

    Why are you using Request.Form anyway?  That's not how we access textbox or any other posted values in  You should be using the control reference that gives you to use to get at the value.  I'd have to guess if you look at the HTML source, you'll see that your textbox has a funky ID now, which you should never try to "guess" in code.

    Author Comment

    Both experts provided solutions that helped resolve the problem.  I'm going to split points but for some reason the Split Points page is not working (won't let me select more than one answer).  I'll contact EE to see if I can get it resolved.  Thanks for the help.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    AJAX ModalPopupExtender has a required property "TargetControlID" which may seem to be very confusing to new users. It means the server control that will be extended by the ModalPopup, for instance, if when you click a button, a ModalPopup displays,…
    Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now