R
rodrigo
This is what I am doing
public class GridCustomPaging : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DgSearch;
protected System.Web.UI.HtmlControls.HtmlForm frmsearch;
protected System.Web.UI.WebControls.Label CurrentPage;
protected System.Web.UI.WebControls.Label TotalPages;
protected System.Web.UI.WebControls.LinkButton FirstPage;
protected System.Web.UI.WebControls.LinkButton PreviousPage;
protected System.Web.UI.WebControls.LinkButton NextPage;
protected System.Web.UI.WebControls.LinkButton LastPage;
protected System.Web.UI.WebControls.TextBox Categories1_Textsearch;
protected Int32 _currentPageNumber = 1;
private void Page_load(object sender, System.EventArgs e)
{
if ( !Page.IsPostBack )
{
BindData();
}
}
private void BindData()
{
Response.Write(Categories1_Textsearch.Text);
}
At this point I get this error: Object reference not set to an
instance of an object.
I tryed these two options:
Categories1_Textsearch =
(TextBox)this.Page.Parent.FindControl("Categories1_Textsearch");
and
Categories1_Textsearch =
(TextBox)this.Page.FindControl("Categories1_Textsearch");
Still get the same error
Do I have to reference the ascx control page inside codebehind? How to
do it?
categories.ascx is the control page.
Categories1_Textsearch is the name of the textbox inside
categories.ascx. Actually the original name is only Textsearch, but
Frameworks, renames it behind the scenes. Categories1_Textsearch is
what I see in the source of the html.
I tried to expose the public properties with no success. But that does
not work since both the aspx and ascx are using codebehind.
Thanks
Rod
public class GridCustomPaging : System.Web.UI.Page
{
protected System.Web.UI.WebControls.DataGrid DgSearch;
protected System.Web.UI.HtmlControls.HtmlForm frmsearch;
protected System.Web.UI.WebControls.Label CurrentPage;
protected System.Web.UI.WebControls.Label TotalPages;
protected System.Web.UI.WebControls.LinkButton FirstPage;
protected System.Web.UI.WebControls.LinkButton PreviousPage;
protected System.Web.UI.WebControls.LinkButton NextPage;
protected System.Web.UI.WebControls.LinkButton LastPage;
protected System.Web.UI.WebControls.TextBox Categories1_Textsearch;
protected Int32 _currentPageNumber = 1;
private void Page_load(object sender, System.EventArgs e)
{
if ( !Page.IsPostBack )
{
BindData();
}
}
private void BindData()
{
Response.Write(Categories1_Textsearch.Text);
}
At this point I get this error: Object reference not set to an
instance of an object.
I tryed these two options:
Categories1_Textsearch =
(TextBox)this.Page.Parent.FindControl("Categories1_Textsearch");
and
Categories1_Textsearch =
(TextBox)this.Page.FindControl("Categories1_Textsearch");
Still get the same error
Do I have to reference the ascx control page inside codebehind? How to
do it?
categories.ascx is the control page.
Categories1_Textsearch is the name of the textbox inside
categories.ascx. Actually the original name is only Textsearch, but
Frameworks, renames it behind the scenes. Categories1_Textsearch is
what I see in the source of the html.
I tried to expose the public properties with no success. But that does
not work since both the aspx and ascx are using codebehind.
Thanks
Rod