You are currently browsing the category archive for the ‘Visual Studio 2005’ category.

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 »

Hey, just got a tip from a friend, Steve. This tip will help prevent the issue of double quotes or no double quotes around javascript for the language attribute.

In Visual Studio 2005, go to Tools>Options> Text Editor > HTML > Format > Check both:

  • “Insert attribute value quotes when typing”
  • “Insert attribute value quotes for formatting”

This will ensure all attribute values, such as the javascript value of the language attribute is always surrounded with quotes.

Thank you Steve.