Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6593021
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:37:44+00:00 2026-05-25T17:37:44+00:00

I have a master page which has a content section with the id cpMainContent.

  • 0

I have a master page which has a content section with the id cpMainContent.
I am using this master page on every webform I am creating for college project. One of such form is frmSearchPersonnel. The purpose of frmSearchPersonnel is to ask user last name of the person they want to search in a textbox and then click on search button. The ID of TextBox is

        txtSearchName

Search button will do postbackUrl transfer to another form which I have named frmViewPersonnel.
In frmViewPersonnel I am trying to use following code.

        NameValueCollection myRequest = Request.Form;
        if(!string.IsEmptyOrNull(myRequest["txtSearchName"]))
           string strSearch = myRequest["txtSearchName"];

The problem I ran into is that this didn’t find any control with the name of txtSearchName. While debugging I found this in myRequest object,

                [5] "ctl00$cpMainContent$txtSearchName" string

Even though when I added textbox I gave it ID of txtSearchName but when page is rendered it is adding extra string from master page.

  1. How can I stop this? I have to use master page so don’t say not to use master page 🙂
  2. Why is it doing that?

Update

While Googling and Binging I found that I can use Control.ClientID in this case so looking into it.

Update 2

As suggested below to add ClientIDMode=”static” in the html of control or add it in page directive. What it does is, it keeps the ID static to txtSearchName but problem is this,

         <input name="ctl00$cpMainContent$txtSearchName" type="text" id="txtSearchName" />

Here name is still using ctl00 and the code I showed above,

            string strSearch = myRequest["txtSearchName"] 

it still won’t work because nvc collection is either searchable by index or name not the id directly.

==============
enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T17:37:45+00:00Added an answer on May 25, 2026 at 5:37 pm

    If you are posting to another page that uses the same master page (called SiteMaster in my case), the name of the textbox should be same the same.

    string val = Request[((SiteMaster)Master).txtSearchName.UniqueID];
    

    If you’re NOT posting to a page with the same master, well, then are you using the viewstate for the textbox at all since you’re posting to another page? If not, just make the control a non asp.net control:

    <input type="text" name="txtSearchName"/>
    

    If you are using viewstate and posting to another page with a different master page, well, you should use PreviousPage.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a master page in my asp.net MVC project, which has code like
I have a content page which has a related master page. I register a
I have an aspx master/content page scenario. The parent page has an IFrame which
I have a master page that has two content sections like this (left some
I have a Master Page which has an associated css file. On one of
I have one master page which applies to all pages in this website. On
I have a master page which has several ContentPlaceHolders. Not all of them are
I have an ASP.net page which uses a master page. The master page has
I have a master page called MasterPage.master which has a <fieldset> with a <legend>
I have a master page which has some user controls within an update panel.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.