I'm trying to submit the below form where a master page is applied.
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<p>
What is your name?
<asp:TextBox ID="YourName" runat="server" ClientIDMode="Static"></asp:TextBox>
</p>
<p>
What is your age?
<asp:TextBox ID="YourAge" runat="server" Columns="3" ClientIDMode="Static"></asp:TextBox>
</p>
<p>
What is your favorite color?<br />
<asp:RadioButtonList ID="FavoriteColor" runat="server" ClientIDMode="Static">
<asp:ListItem Selected="True">Red</asp:ListItem>
<asp:ListItem>Green</asp:ListItem>
<asp:ListItem>Blue</asp:ListItem>
</asp:RadioButtonList>
</p>
<p>
<asp:CheckBox ID="EatGreenEggsAndHam" runat="server" Checked="True" ClientIDMode="Static"
Text="Will You Eat Green Eggs and Ham?" TextAlign="Left" />
</p>
<p>
<asp:Button ID="SubmitButton" runat="server" Text="Submit Form"
PostBackUrl="~/About.aspx"
onclick="SubmitButton_Click" />
</p>
</asp:Content>
I'm trying to use POST method to get submitted data from the form.
in About.aspx page i'm using the below code
Response.Write(Request.Form["YourName"].ToString());
expected behavior is to print the name typed in textbox with the id "YourAge" but the submitted form element ids have changed like below
ctl00$MainContent$YourName
why does this happen? i need to get the value of the control with the id "YourName"
I want to remove this "ctl00$MainContent$" part when submitting form. retrieving the form values are out of my scope and it's done by some other people. They only require form values to be submitted as "YourName" not "ctl00$MainContent$YourName"