Showing posts with label field. Show all posts
Showing posts with label field. Show all posts

Thursday, March 22, 2012

Tags inside value field of appsettings in web.config

i need to write a xml data inside the value field in web.config file.
it looks likes this

<configuration>
<appSettings>
<add key="MyXmlData" value="<data><type></type>......." />
</appSettings>
</configuration
but i get an error message

some one help meYou need to encode/escape the characters. You can do it manually if you
know all of the rules, but I wrote a little utility for myself that I
know will do it right. I guess I should post the full app at some point,
but the relevant method is:

public string Encode(string input)
{
StringBuilder output = new StringBuilder();
using (StringWriter stringWriter = new StringWriter(output,
CultureInfo.InvariantCulture))
{

XmlTextWriter xmlWriter = new XmlTextWriter(stringWriter);
xmlWriter.WriteStartElement("element");
xmlWriter.WriteAttributeString("attribute", input);
xmlWriter.WriteEndElement();
xmlWriter.Close();
}
return output.ToString();
}

Just create a simple WinForms app with a textbox to past a value into, a
button that runs the Encode method, and then a textbox for the output
(not label - you want to be able to select the output for copy/paste).

Joshua Flanagan
http://flimflan.com/blog

Tags inside value field of appsettings in web.config

i need to write a xml data inside the value field in web.config file.
it looks likes this
<configuration>
<appSettings>
<add key="MyXmlData" value="<data><type></type>......." />
</appSettings>
</configuration>
but i get an error message
some one help meYou need to encode/escape the characters. You can do it manually if you
know all of the rules, but I wrote a little utility for myself that I
know will do it right. I guess I should post the full app at some point,
but the relevant method is:
public string Encode(string input)
{
StringBuilder output = new StringBuilder();
using (StringWriter stringWriter = new StringWriter(output,
CultureInfo.InvariantCulture))
{
XmlTextWriter xmlWriter = new XmlTextWriter(stringWriter);
xmlWriter.WriteStartElement("element");
xmlWriter.WriteAttributeString("attribute", input);
xmlWriter.WriteEndElement();
xmlWriter.Close();
}
return output.ToString();
}
Just create a simple WinForms app with a textbox to past a value into, a
button that runs the Encode method, and then a textbox for the output
(not label - you want to be able to select the output for copy/paste).
Joshua Flanagan
http://flimflan.com/blog

Tuesday, March 13, 2012

td bgcolor based on variable

Hello, I am fairly new at ASP.Net and I am using 2.0. I am populating a table from a SQL query. If the field is blank/null, I would like to color the background yellow in the. How do I test for the variable and make this happen? Thanks for your help. Jim

This should help

Custom Formatting Based Upon Data

http://www.asp.net/learn/dataaccess/tutorial11vb.aspx?tabid=63


Create a databound envent handler and make the corresponding format according to the data you get. Yeah, the above link a great one and should solve your problem. take a deep look at it. thanks