<?xml version="1.0" encoding="UTF-8"?> <rss version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>Fundamental Provocation &#187; C#.Net</title> <atom:link href="http://www.ajaymatharu.com/tag/cnet/feed/" rel="self" type="application/rss+xml" /><link>http://www.ajaymatharu.com</link> <description>Blog by Ajay Matharu</description> <lastBuildDate>Sun, 06 Nov 2011 15:09:39 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <generator>http://wordpress.org/?v=3.3.1</generator> <xhtml:meta xmlns:xhtml="http://www.w3.org/1999/xhtml" name="robots" content="noindex" /> <item><title>Export grid values in excel</title><link>http://www.ajaymatharu.com/export-grid-values-in-excel/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=export-grid-values-in-excel</link> <comments>http://www.ajaymatharu.com/export-grid-values-in-excel/#comments</comments> <pubDate>Wed, 07 Oct 2009 07:19:02 +0000</pubDate> <dc:creator>Ajay Matharu</dc:creator> <category><![CDATA[.Net]]></category> <category><![CDATA[ASP.Net]]></category> <category><![CDATA[Development]]></category> <category><![CDATA[Visual Studio]]></category> <category><![CDATA[C#]]></category> <category><![CDATA[C#.Net]]></category> <category><![CDATA[Code]]></category> <category><![CDATA[Datatable]]></category> <category><![CDATA[Export]]></category> <category><![CDATA[export records to excel]]></category> <category><![CDATA[gridview]]></category> <category><![CDATA[gridview to excel]]></category><guid isPermaLink="false">http://www.ajaymatharu.com/?p=1179</guid> <description><![CDATA[Following code helps you to import grid values to excel, //Import System.IO in your application for StreamWriter Object //note: excel_file represents the complete physical address of excel file eg C:/myexcel.xls public void export_datagridview_to_excel(DataGridView dgv, string excel_file) { int cols; //open file StreamWriter wr = new StreamWriter(excel_file); //determine the number of columns and write columns to [...]]]></description> <content:encoded><![CDATA[<p>Following code helps you to import grid values to excel,</p><pre class="c-sharp" name="code">
//Import System.IO in your application for StreamWriter Object

//note: excel_file represents the complete physical address of excel file eg  C:/myexcel.xls
public  void export_datagridview_to_excel(DataGridView dgv, string excel_file)
{
int cols;
//open file
StreamWriter wr = new StreamWriter(excel_file);

//determine the number of columns and write columns to file
cols = dgv.Columns.Count;
for (int i = 0; i &lt; cols; i++)
{
wr.Write(dgv.Columns[i].Name.ToString().ToUpper() + “\t”);
}

wr.WriteLine();

//write rows to excel file
for (int i = 0; i &lt; (dgv.Rows.Count - 1); i++)
{
for (int j = 0; j &lt; cols; j++)
{
if (dgv.RowsIdea.Cells[j].Value != null)
wr.Write(dgv.Rows[i].Cells[j].Value + “\t”);
else
{
wr.Write(”\t”);
}
}

wr.WriteLine();
}

//close file
wr.Close();
}</pre>]]></content:encoded> <wfw:commentRss>http://www.ajaymatharu.com/export-grid-values-in-excel/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Numeric Format Strings</title><link>http://www.ajaymatharu.com/numeric-format-strings/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=numeric-format-strings</link> <comments>http://www.ajaymatharu.com/numeric-format-strings/#comments</comments> <pubDate>Sat, 25 Jul 2009 06:03:29 +0000</pubDate> <dc:creator>Ajay Matharu</dc:creator> <category><![CDATA[.Net]]></category> <category><![CDATA[Visual Studio]]></category> <category><![CDATA[ASP.Net]]></category> <category><![CDATA[C#.Net]]></category> <category><![CDATA[format specifier]]></category> <category><![CDATA[format string]]></category> <category><![CDATA[numeric Format]]></category> <category><![CDATA[numeric format strings]]></category> <category><![CDATA[numeric types]]></category> <category><![CDATA[Objects]]></category> <category><![CDATA[vs.net]]></category><guid isPermaLink="false">http://www.ajaymatharu.com/?p=1276</guid> <description><![CDATA[Standard numeric format strings are used to return string equivalents of numeric types in predefined patterns. When used with ToString, a standard numeric format string parameter takes the form. object.ToString ( "Fn" ); where F is a single alphabetic character called the format specifier, and n can be one or more digits called the precision [...]]]></description> <content:encoded><![CDATA[<p>Standard numeric format strings are used to return string equivalents of numeric types in predefined patterns. When used with ToString, a standard numeric format string parameter takes the form.</p><pre class="c-sharp">object.ToString ( "Fn" );</pre><p>where F is a single alphabetic character called the format specifier, and n can be one or more digits called the precision specifier.</p><p>The following table describes the standard numeric format strings. Note that the patterns produced by these format specifiers are influenced by the settings in the Regional Options control panel. Computers using different cultures or different currency settings will display different patterns.</p><table class="data" border="0" cellspacing="1" width="95%" align="center"><col width="20%"></col><col width="25%"></col><col width="55%"></col><tbody><tr><th>Format specifier</th><th>Name</th><th>Description</th></tr><tr><td>C or c</td><td>Currency</td><td>The number is converted to a string that represents a currency amount. The conversion is controlled by the currency format information of the <a href="http://www.ajaymatharu.com/aspxtreme/sys/Globalization/NumberFormatInfoClass.aspx">NumberFormatInfo</a> object used to format the number. The precision specifier indicates the desired number of decimal places. If the precision specifier is omitted, the default currency precision given by the <strong>NumberFormatInfo</strong> is used.</td></tr><tr><td>D or d</td><td>Decimal</td><td>This format is supported for integral types only. The number is converted to a string of decimal digits ( 0-9 ), prefixed by a minus sign if the number is negative. The precision specifier indicates the minimum number of digits desired in the resulting string. If required, the number is padded with zeros to its left to produce the number of digits given by the precision specifier.</td></tr><tr><td>E or e</td><td>Scientific ( exponential )</td><td>The number is converted to a string of the form &#8220;-d.ddd�E+ddd&#8221; or &#8220;-d.ddd�e+ddd&#8221;, where each &#8216;d&#8217; indicates a digit ( 0-9 ). The string starts with a minus sign if the number is negative. One digit always precedes the decimal point. The precision specifier indicates the desired number of digits after the decimal point. If the precision specifier is omitted, a default of six digits after the decimal point is used. The case of the format specifier indicates whether to prefix the exponent with an &#8216;E&#8217; or an &#8216;e&#8217;. The exponent always consists of a plus or minus sign and a minimum of three digits. The exponent is padded with zeros to meet this minimum, if required.</td></tr><tr><td>F or f</td><td>Fixed-point</td><td>The number is converted to a string of the form &#8220;-ddd.ddd�&#8221; where each &#8216;d&#8217; indicates a digit ( 0-9 ). The string starts with a minus sign if the number is negative. The precision specifier indicates the desired number of decimal places. If the precision specifier is omitted, the default numeric precision given by the <strong>NumberFormatInfo</strong> is used.</td></tr><tr><td>G or g</td><td>General</td><td>The number is converted to the most compact decimal form, using fixed or scientific notation. The precision specifier determines the number of significant digits in the resulting string. If the precision specifier is omitted, the number of significant digits is determined by the type of number being converted:</p><ul><li><strong>Int16</strong> or <strong>UInt16</strong>: 5 digits</li><li><strong>Int32</strong> or <strong>UInt32</strong>: 10 digits</li><li><strong>Int64</strong> or <strong>UInt64</strong>: 19 digits</li><li><strong>Single</strong>: 7 digits</li><li><strong>Double</strong>: 15 digits</li><li><strong>Decimal</strong>: 29 digits</li></ul><p>Trailing zeros after the decimal point are removed, and the resulting string contains a decimal point only if required.</p><p>The resulting string uses fixed-point format if the exponent of the number ( as produced by the &#8216;E&#8217; format ) is less than the number of significant digits, and greater than or equal to –4. Otherwise, the resulting string uses scientific format, and the case of the format specifier controls whether the format is prefixed with an &#8216;E&#8217; or an &#8216;e&#8217;.</td></tr><tr><td>N or n</td><td>Number</td><td>The number is converted to a string of the form &#8220;-d,ddd,ddd.ddd�&#8221;, where each &#8216;d&#8217; indicates a digit ( 0-9 ). The string starts with a minus sign if the number is negative. Thousand separators are inserted between each group of three digits to the left of the decimal point. The precision specifier indicates the desired number of decimal places. If the precision specifier is omitted, the default numeric precision given by the <strong>NumberFormatInfo</strong> is used.</td></tr><tr><td>P or p</td><td>Percent</td><td>The number is converted to a string that represents a percent as defined by the <a href="http://www.ajaymatharu.com/aspxtreme/sys/Globalization/NumberFormatInfoClassPercentNegativePattern.aspx">NumberFormatInfo.PercentNegativePattern</a> property or the <a href="http://www.ajaymatharu.com/aspxtreme/sys/Globalization/NumberFormatInfoClassPercentPositivePattern.aspx">NumberFormatInfo.PercentPositivePattern</a> property. If the number is negative, the string produced is defined by the <strong>PercentNegativePattern</strong> and starts with a minus sign. The converted number is multiplied by 100 in order to be presented as a percentage. The precision specifier indicates the desired number of decimal places. If the precision specifier is omitted, the default numeric precision given by <strong>NumberFormatInfo</strong> is used.</td></tr><tr><td>R or r</td><td>Round-trip</td><td>The round-trip specifier guarantees that a numeric value converted to a string will be parsed back into the same numeric value. When a numeric value is formatted using this specifier, it is first tested using the general format, with 15 spaces of precision for a <strong>Double</strong> and 7 spaces of precision for a <strong>Single</strong>. If the value is successfully parsed back to the same numeric value, then it is formatted using the general format specifer. However, if the value is not successfully parsed back to the same numeric value, then the value is formatted using 17 digits of precision for a <strong>Double</strong> and 9 digits of precision for a <strong>Single</strong>. Although a precision specifier can be appended to the round-trip format specifier, it is ignored. Round trips are given precedence over precision when using this specifier. This format is supported by floating-point types only.</td></tr><tr><td>X or x</td><td>Hexadecimal</td><td>The number is converted to a string of hexadecimal digits. The case of the format specifier indicates whether to use uppercase or lowercase characters for the hexadecimal digits greater than 9. For example, use &#8216;X&#8217; to produce &#8216;ABCDEF&#8217;, and &#8216;x&#8217; to produce &#8216;abcdef&#8217;. The precision specifier indicates the minimum number of digits desired in the resulting string. If required, the number is padded with zeros to its left to produce the number of digits given by the precision specifier. This format is supported for integral types only.</td></tr></tbody></table> ]]></content:encoded> <wfw:commentRss>http://www.ajaymatharu.com/numeric-format-strings/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>control does not exists in current context</title><link>http://www.ajaymatharu.com/control-does-not-exists-in-current-context/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=control-does-not-exists-in-current-context</link> <comments>http://www.ajaymatharu.com/control-does-not-exists-in-current-context/#comments</comments> <pubDate>Wed, 22 Jul 2009 17:24:49 +0000</pubDate> <dc:creator>Ajay Matharu</dc:creator> <category><![CDATA[.Net]]></category> <category><![CDATA[ASP.Net]]></category> <category><![CDATA[Visual Studio]]></category> <category><![CDATA[.net controls]]></category> <category><![CDATA[C#]]></category> <category><![CDATA[C#.Net]]></category> <category><![CDATA[context]]></category> <category><![CDATA[Dot Net]]></category> <category><![CDATA[VB]]></category> <category><![CDATA[vb.net]]></category> <category><![CDATA[visual studio.net]]></category> <category><![CDATA[vs.net]]></category><guid isPermaLink="false">http://ajaymatharu.wordpress.com/?p=665</guid> <description><![CDATA[Another one of those problems that can stump you for a while. I often make backups of files as I progress and sometimes leave them in the website folder, this was fine with classic ASP but as I have found with ASP.Net can cause all sorts of problems.One issue I was having was trying to [...]]]></description> <content:encoded><![CDATA[<p><span style="font-size:85%;">Another one of those problems that can stump you for a while. I often make backups of files as I progress and sometimes leave them in the website folder, this was fine with classic ASP but as I have found with ASP.Net can cause all sorts of problems.</span><span style="font-size:85%;">One issue I was having was trying to reference a component in my aspx page from the codebehind page and seeing the following error when trying to reference a label control:</span></p><blockquote><p><span style="font-size:85%;">“Label2 does not exist in the current context”</span></p></blockquote><p><span style="font-size:85%;">So I found that the problem was even though I renamed one of my old files it still contained the class that my codebehind was referencing (i.e. the class names were still the same) &#8211; and therefore was not seeing the newly added Label control to my new code.</span><span style="font-size:85%;">Shame the compiler doesn’t realise the duplication and give some indication.</span></p><p>Lesson: Remove any backed up files from the web folder and/or build directory to avoid pain <img class="wp-smiley" src="http://s.wordpress.com/wp-includes/images/smilies/icon_smile.gif" alt=")" /></p> ]]></content:encoded> <wfw:commentRss>http://www.ajaymatharu.com/control-does-not-exists-in-current-context/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>MD5 Encryption in .Net and PHP</title><link>http://www.ajaymatharu.com/md5-encryption-in-net-and-php/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=md5-encryption-in-net-and-php</link> <comments>http://www.ajaymatharu.com/md5-encryption-in-net-and-php/#comments</comments> <pubDate>Fri, 12 Jun 2009 04:32:32 +0000</pubDate> <dc:creator>Ajay Matharu</dc:creator> <category><![CDATA[.Net]]></category> <category><![CDATA[PHP]]></category> <category><![CDATA[Visual Studio]]></category> <category><![CDATA[ASP.Net]]></category> <category><![CDATA[C#.Net]]></category> <category><![CDATA[Development]]></category> <category><![CDATA[Encryption]]></category> <category><![CDATA[MD5]]></category> <category><![CDATA[vs.net]]></category><guid isPermaLink="false">http://www.ajaymatharu.com/?p=1273</guid> <description><![CDATA[To get MD5 hash in C# use this method. It returns same value AS MD5() function in PHP public string GetMD5Hash(string input) { System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider(); byte[] bs = System.Text.Encoding.UTF8.GetBytes(input); bs = x.ComputeHash(bs); System.Text.StringBuilder s = new System.Text.StringBuilder(); foreach (byte b in bs) { s.Append(b.ToString("x2").ToLower()); } string password = s.ToString(); return password; } [...]]]></description> <content:encoded><![CDATA[<p>To get MD5 hash in C#  use this method. It returns same value AS MD5() function in PHP</p><pre name="code" clas="c-sharp">
        public string GetMD5Hash(string input)
        {
            System.Security.Cryptography.MD5CryptoServiceProvider x = new System.Security.Cryptography.MD5CryptoServiceProvider();
            byte[] bs = System.Text.Encoding.UTF8.GetBytes(input);
            bs = x.ComputeHash(bs);
            System.Text.StringBuilder s = new System.Text.StringBuilder();
            foreach (byte b in bs)
            {
                s.Append(b.ToString("x2").ToLower());
            }
            string password = s.ToString();
            return password;
        }
</pre><p>And this one is in PHP</p><pre name="code" class="php">
<?php
echo md5("pathfinder");
?>
</pre><p>These both will return the same value</p> ]]></content:encoded> <wfw:commentRss>http://www.ajaymatharu.com/md5-encryption-in-net-and-php/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Impersonation in Sharepoint &#8211; MOSS/WSS</title><link>http://www.ajaymatharu.com/impersonation-in-sharepoint-mosswss/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=impersonation-in-sharepoint-mosswss</link> <comments>http://www.ajaymatharu.com/impersonation-in-sharepoint-mosswss/#comments</comments> <pubDate>Wed, 10 Jun 2009 04:42:12 +0000</pubDate> <dc:creator>Ajay Matharu</dc:creator> <category><![CDATA[.Net]]></category> <category><![CDATA[ASP.Net]]></category> <category><![CDATA[Sharepoint]]></category> <category><![CDATA[C#.Net]]></category> <category><![CDATA[Impersonation]]></category> <category><![CDATA[Microsoft]]></category> <category><![CDATA[MOSS]]></category> <category><![CDATA[Visual Studio]]></category> <category><![CDATA[vs.net]]></category> <category><![CDATA[WSS]]></category><guid isPermaLink="false">http://www.ajaymatharu.com/?p=1349</guid> <description><![CDATA[Here is the little code that you can use to impersonate any user in sharepoint. This will code will pretend that you are logged in as the user who is impersonated and will be allowed access to all the features and inherits all the rights for that person. This is mainly used to do something [...]]]></description> <content:encoded><![CDATA[<p>Here is the little code that you can use to impersonate any user in sharepoint. This will code will pretend that you are logged in as the user who is impersonated and will be allowed access to all the features and inherits all the rights for that person. This is mainly used to do something for which the impersonating person has rights and you other user do not have rights.</p><pre name="code" class="c-sharp">
SPWeb web = SPContext.Current.Web.Site.OpenWeb();
SPUser user = web.AllUsers[username];
SPUserToken userToken = user.UserToken;
SPSite site = new SPSite(SPContext.Current.Web.Site.Url.ToString(), userToken);
web = site.OpenWeb();
</pre><p>Here username is the name username of the user who you want to impersonate as.</p><p>Hope this helps <img src='http://www.ajaymatharu.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://www.ajaymatharu.com/impersonation-in-sharepoint-mosswss/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Simple code to loop through all the textboxes in your page</title><link>http://www.ajaymatharu.com/simple-code-to-loop-through-all-the-textboxes-in-your-page/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=simple-code-to-loop-through-all-the-textboxes-in-your-page</link> <comments>http://www.ajaymatharu.com/simple-code-to-loop-through-all-the-textboxes-in-your-page/#comments</comments> <pubDate>Tue, 05 May 2009 04:15:22 +0000</pubDate> <dc:creator>Ajay Matharu</dc:creator> <category><![CDATA[.Net]]></category> <category><![CDATA[ASP.Net]]></category> <category><![CDATA[Development]]></category> <category><![CDATA[Visual Studio]]></category> <category><![CDATA[C#.Net]]></category> <category><![CDATA[vs.net]]></category><guid isPermaLink="false">http://www.ajaymatharu.com/?p=1188</guid> <description><![CDATA[This is the simple code you can use, to loop through all the textboxes in your page. Not only textboxes you can change the textbox in &#8220;(ctrl is Textbox)&#8221; to the control you&#8217;ll like to loop in your page. private void processTextbox() { foreach (Control ctrl in Page.Controls) { if (ctrl is TextBox) { //do [...]]]></description> <content:encoded><![CDATA[<p>This is the simple code you can use, to loop through all the textboxes in your page. Not only textboxes you can change the textbox in<br /> <em><strong>&#8220;(ctrl is Textbox)&#8221;</strong></em> to the control you&#8217;ll like to loop in your page.</p><pre name="code" class="c-sharp">
 private  void processTextbox()
{
     foreach (Control ctrl in Page.Controls)
     {
          if (ctrl is TextBox)
          {
              //do something here
          }
          else
          {
              //do something here
          }
     }
}
</pre><p>Njoy coding <img src='http://www.ajaymatharu.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /></p> ]]></content:encoded> <wfw:commentRss>http://www.ajaymatharu.com/simple-code-to-loop-through-all-the-textboxes-in-your-page/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Code to convert any image format</title><link>http://www.ajaymatharu.com/code-to-convert-any-image-format/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=code-to-convert-any-image-format</link> <comments>http://www.ajaymatharu.com/code-to-convert-any-image-format/#comments</comments> <pubDate>Fri, 01 May 2009 17:34:59 +0000</pubDate> <dc:creator>Ajay Matharu</dc:creator> <category><![CDATA[.Net]]></category> <category><![CDATA[ASP.Net]]></category> <category><![CDATA[Visual Studio]]></category> <category><![CDATA[C#.Net]]></category> <category><![CDATA[C-Sharp]]></category> <category><![CDATA[Image Conversion]]></category><guid isPermaLink="false">http://www.ajaymatharu.com/?p=1161</guid> <description><![CDATA[The following code converts any image format, public void ConvertImage2Jpeg(string input, string output) { try { ImageCodecInfo myimagecodeinfo; string inputpath; string outputpath = output; string format; inputpath = input; format = inputpath.Substring(inputpath.LastIndexOf(".") + 1); if (format == "tif") { myimagecodeinfo = GetEncoderInfo("image/tiff"); } else { myimagecodeinfo = GetEncoderInfo("image/" + format); } EncoderParameters eparam = new [...]]]></description> <content:encoded><![CDATA[<p>The following code converts any image format,</p><pre name="code" class="c-sharp">public void ConvertImage2Jpeg(string input, string output)
{
try
{
ImageCodecInfo myimagecodeinfo;
string inputpath;
string outputpath = output;
string format;
inputpath = input;
format = inputpath.Substring(inputpath.LastIndexOf(".") + 1);

if (format == "tif")
{
myimagecodeinfo = GetEncoderInfo("image/tiff");

}
else
{
myimagecodeinfo = GetEncoderInfo("image/" + format);

}
EncoderParameters eparam = new EncoderParameters(1);
EncoderParameter encparam;
System.Drawing.Imaging.Encoder enc;
enc = System.Drawing.Imaging.Encoder.Transformation;
encparam = new EncoderParameter(enc, (long)EncoderValue.TransformRotate90);
eparam.Param[0] = new EncoderParameter(System.Drawing.Imaging.Encoder.Quality, 10L);
string jpg;
Image img;
img = Image.FromFile(inputpath);
jpg = outputpath.Substring(0, outputpath.LastIndexOf("\\") + 1) + Path.GetFileNameWithoutExtension(inputpath) + ".JPG";
img.Save(jpg, myimagecodeinfo, eparam);

}
catch (Exception exp)
{

}

}

private static ImageCodecInfo GetEncoderInfo(String mimeType)
{
int j;
ImageCodecInfo[] encoders;
encoders = ImageCodecInfo.GetImageEncoders();
for (j = 0; j &lt; encoders.Length; ++j)
{
if (encoders[j].MimeType == mimeType)
return encoders[j];
}
return null;
}</pre>]]></content:encoded> <wfw:commentRss>http://www.ajaymatharu.com/code-to-convert-any-image-format/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Cannot read value from readonly textbox</title><link>http://www.ajaymatharu.com/cannot-read-value-from-readonly-textbox/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=cannot-read-value-from-readonly-textbox</link> <comments>http://www.ajaymatharu.com/cannot-read-value-from-readonly-textbox/#comments</comments> <pubDate>Sat, 04 Apr 2009 11:37:09 +0000</pubDate> <dc:creator>Ajay Matharu</dc:creator> <category><![CDATA[.Net]]></category> <category><![CDATA[Development]]></category> <category><![CDATA[Microsoft]]></category> <category><![CDATA[Technical]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[Visual Studio]]></category> <category><![CDATA[C#.Net]]></category> <category><![CDATA[vs.net]]></category><guid isPermaLink="false">http://ajaymatharu.wordpress.com/?p=667</guid> <description><![CDATA[While working on the project we came across a problem that, we were not able to read value of read only text box, i.e. TextBox1.Text returned nothing even when the text box had value. On googling, I found after doing this you can make your text box read only and also it will return the [...]]]></description> <content:encoded><![CDATA[<p>While working on the project we came across a problem that, we were not able to read value of read only text box, i.e. TextBox1.Text returned nothing even when the text box had value.</p><p>On googling, I found after doing this you can make your text box read only and also it will return the value of the text box. You need to insert this line on your Page_Load</p><p>TextBox1.Attributes.Add(&#8220;readonly&#8221;, &#8220;true&#8221;);</p> ]]></content:encoded> <wfw:commentRss>http://www.ajaymatharu.com/cannot-read-value-from-readonly-textbox/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>Gridview &#8211; Client side sorting and paging</title><link>http://www.ajaymatharu.com/gridview-client-side-sorting-and-paging/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=gridview-client-side-sorting-and-paging</link> <comments>http://www.ajaymatharu.com/gridview-client-side-sorting-and-paging/#comments</comments> <pubDate>Thu, 26 Feb 2009 13:00:27 +0000</pubDate> <dc:creator>Ajay Matharu</dc:creator> <category><![CDATA[.Net]]></category> <category><![CDATA[ASP.Net]]></category> <category><![CDATA[Development]]></category> <category><![CDATA[Microsoft]]></category> <category><![CDATA[Technical]]></category> <category><![CDATA[Technology]]></category> <category><![CDATA[Visual Studio]]></category> <category><![CDATA[Agile Development]]></category> <category><![CDATA[C#.Net]]></category> <category><![CDATA[vs.net]]></category><guid isPermaLink="false">http://ajaymatharu.wordpress.com/?p=842</guid> <description><![CDATA[The GridView control provides you with the option of sorting and paging records without requiring a form-post back to the Web server. In other words, you can re-render the contents of a GridView when sorting and paging, without needing to re-render the entire page. You enable client paging and sorting by assigning the value true [...]]]></description> <content:encoded><![CDATA[<p></p><div style="background:white none repeat scroll 0 0;font-family:Courier New;font-size:10pt;color:black;"><p>The <strong>GridView</strong> control provides you with the option of sorting and paging records without requiring a form-post back to the Web server. In other words, you can re-render the contents of a <strong>GridView</strong> when sorting and paging, without needing to re-render the entire page.</p><p>You enable client paging and sorting by assigning the value <strong>true</strong> to the <strong>EnableSortingAndPagingCallback</strong> property. When this property has the value <strong>true</strong>, the <strong>GridView</strong> uses JavaScript to request an updated set of records from the Web server.</p><p style="margin:0;"><span style="color:red;"><br /> </span></p><p style="margin:0;"><p style="margin:0;"><span style="color:red;"> 1</span> <span style="background:#ffee62 none repeat scroll 0 0;">&lt;%</span><span style="color:blue;">@</span> <span style="color:#a31515;">Page</span> <span style="color:red;">Language</span><span style="color:blue;">=&#8221;C#&#8221;</span> <span style="color:red;">AutoEventWireup</span><span style="color:blue;">=&#8221;true&#8221;</span> <span style="color:red;">CodeFile</span><span style="color:blue;">=&#8221;Default.aspx.cs&#8221;</span> <span style="color:red;">Inherits</span><span style="color:blue;">=&#8221;_Default&#8221;</span> <span style="background:#ffee62 none repeat scroll 0 0;">%&gt;</span></p><p style="margin:0;"><span style="color:red;"> 2</span></p><p style="margin:0;"><span style="color:red;"> 3</span> <span style="color:blue;">&lt;!</span><span style="color:#a31515;">DOCTYPE</span> <span style="color:red;">html</span> <span style="color:red;">PUBLIC</span> <span style="color:blue;">&#8220;-//W3C//DTD XHTML 1.0 Transitional//EN&#8221;</span> <span style="color:blue;">&#8220;http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd&#8221;&gt;</span></p><p style="margin:0;"><span style="color:red;"> 4</span> <span style="color:blue;">&lt;</span><span style="color:#a31515;">html</span><span style="color:blue;">&gt;</span></p><p style="margin:0;"><span style="color:red;"> 5</span> <span style="color:blue;">&lt;</span><span style="color:#a31515;">head</span> <span style="color:red;">id</span><span style="color:blue;">=&#8221;Head1&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;&gt;</span></p><p style="margin:0;"><span style="color:red;"> 6</span> <span style="color:blue;">&lt;</span><span style="color:#a31515;">title</span><span style="color:blue;">&gt;</span>Callback GridView<span style="color:blue;">&lt;/</span><span style="color:#a31515;">title</span><span style="color:blue;">&gt;</span></p><p style="margin:0;"><span style="color:red;"> 7</span> <span style="color:blue;">&lt;/</span><span style="color:#a31515;">head</span><span style="color:blue;">&gt;</span></p><p style="margin:0;"><span style="color:red;"> 8</span> <span style="color:blue;">&lt;</span><span style="color:#a31515;">body</span><span style="color:blue;">&gt;</span></p><p style="margin:0;"><span style="color:red;"> 9</span> <span style="color:blue;">&lt;</span><span style="color:#a31515;">form</span> <span style="color:red;">id</span><span style="color:blue;">=&#8221;Form1&#8243;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;server&#8221;&gt;</span></p><p style="margin:0;"><span style="color:red;"> 10</span> <span style="background:#ffee62 none repeat scroll 0 0;">&lt;%</span><span style="color:blue;">=</span><span style="color:#2b91af;">DateTime</span>.Now <span style="background:#ffee62 none repeat scroll 0 0;">%&gt;</span></p><p style="margin:0;"><span style="color:red;"> 11</span> <span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">GridView</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;GridView1&#8243;</span> <span style="color:red;">DataSourceID</span><span style="color:blue;">=&#8221;TitlesSource&#8221;</span> <span style="color:red;">EnableSortingAndPagingCallbacks</span><span style="color:blue;">=&#8221;true&#8221;</span></p><p style="margin:0;"><span style="color:red;"> 12</span> <span style="color:red;">AllowPaging</span><span style="color:blue;">=&#8221;true&#8221;</span> <span style="color:red;">AllowSorting</span><span style="color:blue;">=&#8221;true&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;Server&#8221;</span> <span style="color:blue;">/&gt;</span></p><p style="margin:0;"><span style="color:red;"> 13</span> <span style="color:blue;">&lt;</span><span style="color:#a31515;">asp</span><span style="color:blue;">:</span><span style="color:#a31515;">SqlDataSource</span> <span style="color:red;">ID</span><span style="color:blue;">=&#8221;TitlesSource&#8221;</span> <span style="color:red;">ConnectionString</span><span style="color:blue;">=&#8221;Server=localhost;Database=northwind;Trusted_Connection=true&#8221;</span></p><p style="margin:0;"><span style="color:red;"> 14</span> <span style="color:red;">SelectCommand</span><span style="color:blue;">=&#8221;SELECT * FROM customers&#8221;</span> <span style="color:red;">runat</span><span style="color:blue;">=&#8221;Server&#8221;</span> <span style="color:blue;">/&gt;</span></p><p style="margin:0;"><span style="color:red;"> 15</span> <span style="color:blue;">&lt;/</span><span style="color:#a31515;">form</span><span style="color:blue;">&gt;</span></p><p style="margin:0;"><span style="color:red;"> 16</span> <span style="color:blue;">&lt;/</span><span style="color:#a31515;">body</span><span style="color:blue;">&gt;</span></p><p style="margin:0;"><span style="color:red;"> 17</span> <span style="color:blue;">&lt;/</span><span style="color:#a31515;">html</span><span style="color:blue;">&gt;</span></p><p style="margin:0;"><span style="color:blue;"><br /> </span></p><p style="margin:0;"><p style="margin:0;"><span style="color:blue;"><span style="color:#000000;">Here when you will sort the page or click on the page number the time will not change as it is being set on the page load but the data will get sorted. </span></span>The time doesn&#8217;t change because the page is not reloaded.</p><p style="margin:0;"><p style="margin:0;">Behind the scenes, the <strong>GridView</strong> uses the Microsoft Internet Explorer <strong>XMLHTTPRequest</strong> object to communicate with the Web server. This object is supported by Internet Explorer version 5.0 and higher.</p><p style="margin:0;"><p style="margin:0;">However this does not work when you have a templatefield in your Gridview. If you have a templatefield in your Gridview you need to perform the pagination like traditional way handling the events.</p></div> ]]></content:encoded> <wfw:commentRss>http://www.ajaymatharu.com/gridview-client-side-sorting-and-paging/feed/</wfw:commentRss> <slash:comments>1</slash:comments> </item> <item><title>Insert Code Snippet &#8211; Tip Of Week #15</title><link>http://www.ajaymatharu.com/insert-code-snippet-tip-of-week-15/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=insert-code-snippet-tip-of-week-15</link> <comments>http://www.ajaymatharu.com/insert-code-snippet-tip-of-week-15/#comments</comments> <pubDate>Mon, 29 Dec 2008 05:51:17 +0000</pubDate> <dc:creator>Ajay Matharu</dc:creator> <category><![CDATA[.Net]]></category> <category><![CDATA[Tip of Week]]></category> <category><![CDATA[Visual Studio]]></category> <category><![CDATA[C#.Net]]></category> <category><![CDATA[Developer]]></category> <category><![CDATA[Development]]></category> <category><![CDATA[Microsoft]]></category> <category><![CDATA[Visual Studio Tip]]></category> <category><![CDATA[Visual Studio Tip Of Week]]></category> <category><![CDATA[Visual Studio tips]]></category> <category><![CDATA[vs.net]]></category><guid isPermaLink="false">http://ajaymatharu.wordpress.com/?p=693</guid> <description><![CDATA[Hi guys, do you know you can use already ready code inside your visual studio? Yes certainly you can insert code snippets into your code. You can invoke the &#8220;Insert Snippet&#8221; by using shortcut &#8220;ctrl k + ctrl x&#8221;. You can download some of the code snippets from http://msdn.microsoft.com/en-us/vstudio/aa718338.aspx all you need to do is [...]]]></description> <content:encoded><![CDATA[<p>Hi guys, do you know you can use already ready code inside your visual studio? Yes certainly you can insert code snippets into your code. You can invoke the &#8220;Insert Snippet&#8221; by using shortcut &#8220;ctrl k + ctrl x&#8221;.</p><p><img class="aligncenter size-full wp-image-694" title="snippet" src="http://ajaymatharu.files.wordpress.com/2008/12/snippet.jpg" alt="snippet" width="500" height="221" /></p><p>You can download some of the code snippets from http://msdn.microsoft.com/en-us/vstudio/aa718338.aspx  all you need to do is install this file at &#8220;My Documents\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets&#8221; location. You can also find some more snippets at  http://www.codeplex.com/snippetlibcsharp/Release/ProjectReleases.aspx?ReleaseId=14841  all you need to do is copy this snippet at &#8220;My Documents\Visual Studio 2008\Code Snippets\Visual C#\My Code Snippets&#8221; and you are ready to use these ready made code into your visual studio using shortcuts &#8220;ctrl k + ctrl x&#8221;</p><p>You can also insert the snippets by writing a part of it and pressing tab twice. For e.g. to insert a new property in your code type</p><p>prop + tab + tab</p><p>this will insert a property in your code window.</p><p>So keep using this to improve your productivity, and enjoy coding.</p><p>:Ajay Matharu</p> ]]></content:encoded> <wfw:commentRss>http://www.ajaymatharu.com/insert-code-snippet-tip-of-week-15/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
