Reputation: 4261
how can i get the value of input control from masterpage ?
my master page:
.......
<div class="searchform">
<form id="formsearch" name="formsearch" method="post" action="#">
<span>
<input name="editbox_search" class="editbox_search" id="editbox_search" maxlength="80" value="Code Client:" type="text" />
</span>
<input name="button_search" src="images/search_btn.gif" class="button_search" type="image" />
</form>
</div>
</div>
<div class="clr"></div>
</div>
</div>
<div class="content">
<div class="content_resize">
<div class="mainbar">
<div class="article">
<form id="form1" runat="server">
<div>
<asp:ContentPlaceHolder id="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</form>
</div>
.....
and my default.aspx that use MasterPAge:
protected void Page_Load(object sender, EventArgs e)
{
Label ClientId = (Label)Master.FindControl("editbox_search");
ASPxLabel_Err.Text = ClientId.Text;
}
i try to convert input Control into Label, because i can not find input control.
but i got nullReference that logic because i can not convert input control into label control.
Upvotes: 0
Views: 2024
Reputation: 3030
var editbox = (HtmlInputControl)Master.FindControl("editbox_search");
Response.Write (editbox.Value);
Upvotes: 1
Reputation: 3
first you need to make this tag as "runat= server" then only you can use:
var txtEditBox =(System.Web.UI.HtmlControls.HtmlInputText)this.Page.Master.FindControl("editbox_search");
ASPxLabel_Err.Text = txtEditBox.Value ;
Upvotes: 0
Reputation: 1082
try this
var mastertxt = (System.Web.UI.HtmlControls.HtmlInputText)Master.FindControl("ctl00$editbox_search");
ASPxLabel_Err.Text = mastertxt.Value;
Upvotes: 0