Problems with empty strings and Properties window

C

Cristian Ionita

I need to be able to set a string property in a control to an empty string
using the properties window.

The problem is that when I set the property to an empty string, Visual
Studio
serializes the property in aspx as:
<cc1:VerySimpleControl id="Vvsc" runat="server" MyString="
"></cc1:VerySimpleControl>
(MyString property contains one space)
instead of:
<cc1:VerySimpleControl id="Vvsc" runat="server"
MyString=""></cc1:VerySimpleControl>
(no spaces)

Is there any workaround for this issue in Visual Studio?

Here is the code for the test control:

public class VerySimpleControl : WebControl
{
public VerySimpleControl()
{
myString = "NotSet";
}

private string myString;
[DefaultValue("NotSet")]
public string MyString
{
get { return myString; }
set { myString = value; }
}

protected override void RenderContents(HtmlTextWriter writer)
{
writer.Write(
"String: '{0}' Length: {1}",
MyString, MyString.Length);

base.RenderContents (writer);
}
}

Cristian Ionita
Regisco S.A.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top