Friday, March 12, 2010
Make the PagerTemplate of GridView to always visible
To show GridView's PagerTemplate row to be visible all the time use the GridView.BottomPagerRow.Visible = true; after calling the DataBind() method.
Tuesday, February 9, 2010
Prevent user from double clicking an ASP.NET button
The snippet below will disable the asp.net standard button control once the user already clicked it.
<asp:button id="btnSubmit" Text="Submit" onclick="btnSubmit_Click" OnClientClick="this.disabled = true; this.value = 'Submitting...';" UseSubmitBehavior="false" />
<asp:button id="btnSubmit" Text="Submit" onclick="btnSubmit_Click" OnClientClick="this.disabled = true; this.value = 'Submitting...';" UseSubmitBehavior="false" />
Thursday, January 7, 2010
XmlWriter defaults to UTF-16 encoding
Whatever your case, you might find a need to alter the encoding type when you are using the XmlWriter class to anything other than UTF-16 which is the default in .NET. I like simplicity so a quick string manipulation will suffice .
private static string SerializeIt(object item)
{
try
{
System.Text.StringBuilder sb = new System.Text.StringBuilder();
using (XmlWriter writer = XmlWriter.Create(sb))
{
XmlSerializer sr = new XmlSerializer(item.GetType());
if (writer != null) sr.Serialize(writer, item);
}
//change the encoding back to UFT-8
sb.Replace(Encoding.Unicode.WebName, Encoding.UTF8.WebName);
return sb.ToString();
}
catch (Exception ex)
{
//do something.
}
}
Monday, December 7, 2009
Download Location of System.Net.WebClient.DownloadFile()
The file will be downloaded by the API depending on where the executing program is running.
i.e. if you have this method declared in a class library, and that class library is consumed in the main appplication, then the file will be downloaded in the main application's bin directory.
i.e. if you have this method declared in a class library, and that class library is consumed in the main appplication, then the file will be downloaded in the main application's bin directory.
Subscribe to:
Comments (Atom)