问题
I have a Master page and one web form inherited from that master page,
the tag is in master page which contains a content place holder inside
Master Page:
<form runat="server">
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</form>
the web form implement that content place holder.
WebForm.aspx:
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:TextBox ID="tbAmount" runat="server" />
</asp:content>
in the code behind web form, I wanna use Request.Form["tbAmount"] to get Text of TextBox.
I know in this case using TextBox.Text will be the easiest way, but dont ask me why, cuz it will take hours to explain.
let's just say I create a TextBox in aspx.cs instead of aspx.
how can I use Request.Form["tbAmount"] to get its Text after it posted back.
回答1:
You will not be able to use Request.Form["tbAmount"] directly, you will have to use the clientid of the textbox
Request.Form[tbAmount.ClientId]
This is because asp.net ID of a control and its corresponsing HTML control's id are not the same, you have to use the ClientId property to accesss it.
来源:https://stackoverflow.com/questions/13466646/how-to-use-request-form-in-inherited-web-form