A
Alan Samet
I know what's causing this, but how do I work around it?
**********************
file: test.master:
**********************
<%@ Master %>
<script runat=server>
void Page_Load(object sender, EventArgs e)
{
DataBind();
}
</script>
**<asp:ContentPlaceHolder runat=server id=main />**
**********************
file: test.aspx
**********************
<%@ Page MasterPageFile="test.master" %>
<script runat=server>
public override void DataBind()
{
throw new Exception();
}
string Expression = "I am Databound";
</script>
<asp:Content runat=server contentplaceholderid=main>
<%# Expression %>
</asp:Content>
**********************
Problem
**********************
DataBind is never called on the aspx file, yet databinding expressions
are still processed. I imagine what's happening is this:
Master page finds all the <asp:content ...> controls in the page file.
Removes them and loads them into the master page a la:
foreach(Control c in LoadedPage.Controls)
{
Content content = c as Content;
if (content == null) continue;
this.FindControl(content.ContentPlaceHolderID).Controls.Add(content);
}
//discard the (aspx) page loaded into memory
DataBind the master page.
There is one thing that I'm missing, and that is if I manually call
"DataBind()" within the page, that databind expression is called as
well. I can't call DataBind() at both the master and the page level
without having it fire twice. Did Microsoft give us a delegate that I
can wire up to to get around this?
-Alan
**********************
file: test.master:
**********************
<%@ Master %>
<script runat=server>
void Page_Load(object sender, EventArgs e)
{
DataBind();
}
</script>
**<asp:ContentPlaceHolder runat=server id=main />**
**********************
file: test.aspx
**********************
<%@ Page MasterPageFile="test.master" %>
<script runat=server>
public override void DataBind()
{
throw new Exception();
}
string Expression = "I am Databound";
</script>
<asp:Content runat=server contentplaceholderid=main>
<%# Expression %>
</asp:Content>
**********************
Problem
**********************
DataBind is never called on the aspx file, yet databinding expressions
are still processed. I imagine what's happening is this:
Master page finds all the <asp:content ...> controls in the page file.
Removes them and loads them into the master page a la:
foreach(Control c in LoadedPage.Controls)
{
Content content = c as Content;
if (content == null) continue;
this.FindControl(content.ContentPlaceHolderID).Controls.Add(content);
}
//discard the (aspx) page loaded into memory
DataBind the master page.
There is one thing that I'm missing, and that is if I manually call
"DataBind()" within the page, that databind expression is called as
well. I can't call DataBind() at both the master and the page level
without having it fire twice. Did Microsoft give us a delegate that I
can wire up to to get around this?
-Alan