You are currently browsing the monthly archive for December 2006.

I stumbled upon another issue. I am sure there is a good reason they decided to not allow this, but I found it quite frustrating to learn it the hard way. Server Control tags, like for a button, or TextBox or any other server control, can not contain .net code <% … %>. For example:

<asp:Button ID=”btnRefreshLayout” runat=”server” Text=”Refresh Layout” OnClientClick=”AdjustFrameDim(<%= _layout%>);” OnClick=”btnRefreshLayout_Click” />

The result is…

<input type=”submit” name=”btnRefreshLayout” value=”Refresh Layout” onclick=”AdjustFrameDim(<%= _layout%>);” id=”BI_TabControl1_ucLayout_btnRefreshLayout” />

It doesn’t seem to matter where in the server control code you put the <% … %>, it doesn’t work.

BUT, I have good news… If you need to dynamically add something to the properties of the server control, you could instead use the AddAttribute method of the server control and get the needed results that way.

btnRefreshLayout.Attributes.Add(“OnClick”, “AdjustFrameDim(“ + _layout + “);”);

Happy Coding.

I am not sure I gave this post an appropriate title, but it works for now.

The Problem:
ASP.Net gives a developer the opportunity to programmatically add controls to a web form using ParentControl.Controls.Add(new Control()); However, these controls are not persisted in any way thus having to be recreated for each subsequent request.

What I found:
On the page I have a PlaceHolder. Depending on the dynamic data at the time of processing, one of 10 “layout” UserControls need to be added to the PlaceHoder. And inside each of those “layouts” will be 2 to 4 “content” UserControls with dynamic data based on the data and properties set by the “layout” UserControl. While stepping Read the rest of this entry »