<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:blogger='http://schemas.google.com/blogger/2008' xmlns:georss='http://www.georss.org/georss' xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-8418220492622156049</id><updated>2024-09-14T16:52:10.773-07:00</updated><category term="Community Server"/><category term="programmatically"/><category term="ASP.Net"/><category term="Blog groups in Community Server"/><category term="C# SQL SERVER NETWORK INSTANCE"/><category term="Community Server Blogs"/><category term="Different UI of Blogs"/><category term="Filter posts"/><category term="MOSS"/><category term="MOSS 2007"/><category term="Multiple tags"/><category term="Network Instance programmatically"/><category term="SQL Server"/><category term="Sharepoint"/><category term="Sharepoint Web Application programmatically"/><category term="create web application programmatically"/><category term="javascript"/><category term="maximum length"/><category term="textarea"/><title type='text'>.Net Tweaks</title><subtitle type='html'>Messing with .Net is an entertainment...! :)</subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://dotnettweaks.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default?redirect=false'/><link rel='alternate' type='text/html' href='http://dotnettweaks.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Mujtaba</name><uri>http://www.blogger.com/profile/06265469390379198539</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE7MZXipftm-BTXUxPmbaYvn5g-7HIyk3BPOC5IxN1McuDMCpc5kwT71NKfWoUBwgJShN-tKRCwmLU0rmfAwOesOkWYkmgVdu07RgHB-puPuIpKvYCBeUdX-g_hTk/s220/IMG_20160315_153740-s.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>13</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-8418220492622156049.post-9114911031824605639</id><published>2011-05-24T11:38:00.000-07:00</published><updated>2011-05-24T11:38:39.572-07:00</updated><title type='text'>Invalid postback or callback argument.  Event validation is enabled using  in configuration....</title><content type='html'>I had a datagridview in which I added an EDIT button so that I click on edit button to edit that records. Whenever I clicked that button I would get this error.&lt;br /&gt;
&lt;blockquote&gt;Invalid postback or callback argument.  Event validation is enabled using &lt;pages enableEventValidation=&quot;true&quot;/&gt; in configuration&lt;/blockquote&gt;&lt;br /&gt;
After googling alot I got some crazy answers like go to web.config and set enableEventValidation to true but this didn&#39;t solved problem. At the end it was simple. Just put your databinding code (in my case LoadData() function) inside IsPostBack like this.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;if (!IsPostBack)&lt;br /&gt;
        {&lt;br /&gt;
            LoadData();&lt;br /&gt;
        }&lt;br /&gt;
&lt;/blockquote&gt;&lt;br /&gt;
Happy coding...:)</content><link rel='replies' type='application/atom+xml' href='http://dotnettweaks.blogspot.com/feeds/9114911031824605639/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dotnettweaks.blogspot.com/2011/05/invalid-postback-or-callback-argument.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/9114911031824605639'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/9114911031824605639'/><link rel='alternate' type='text/html' href='http://dotnettweaks.blogspot.com/2011/05/invalid-postback-or-callback-argument.html' title='Invalid postback or callback argument.  Event validation is enabled using &lt;pages enableEventValidation=&quot;true&quot;/&gt; in configuration....'/><author><name>Mujtaba</name><uri>http://www.blogger.com/profile/06265469390379198539</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE7MZXipftm-BTXUxPmbaYvn5g-7HIyk3BPOC5IxN1McuDMCpc5kwT71NKfWoUBwgJShN-tKRCwmLU0rmfAwOesOkWYkmgVdu07RgHB-puPuIpKvYCBeUdX-g_hTk/s220/IMG_20160315_153740-s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8418220492622156049.post-3941645031321473577</id><published>2011-04-07T00:57:00.000-07:00</published><updated>2011-04-07T01:04:14.167-07:00</updated><title type='text'>Facebook &quot;Like&quot; and &quot;Share&quot; count same -- A work around</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;I have been writing a post here after so long. The thing made me write this is about facebook.&lt;br /&gt;
We had added facebook LIKE and share buttons to our site. The client posted a bug saying the count of LIKE and share buttons is always the same. After doing some googling I found facebook guys saying the count is of interaction of the link with facebook. For example we put it on www.abc.com/xyz.aspx and someone LIKE it, it will increment the interaction. Then if someone share it on facebook this will also increment the interaction.&lt;br /&gt;
I found the work around by chance. :)&lt;br /&gt;
Here it is.&lt;br /&gt;
FB Share button like the one below&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;div class=&quot;dvshare&quot; style=&quot;float: right; width: 120px;&quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;a href=&quot;http://www.facebook.com/sharer.php&quot; name=&quot;fb_share&quot; type=&quot;button_count&quot;&amp;gt;Share&amp;lt;/a&amp;gt;&amp;lt;script&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;src=&quot;http://static.ak.fbcdn.net/connect.php/js/FB.Share&quot; type=&quot;text/javascript&quot;&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
It picks up the current URL from browser, share it and increments the count.&lt;br /&gt;
In my case the URL was like this http://www.mydomain.com/myfolder&lt;br /&gt;
&lt;br /&gt;
The browser automatically adds &quot;/&quot; at the end making it &quot;http://www.mydomain.com/myfolder/&quot;.&lt;br /&gt;
&lt;br /&gt;
The LIKE button however first look for the canonical tag and send canonical tag to facebook.&lt;br /&gt;
&lt;br /&gt;
Fortunately we had added the canonical tag like this.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;pre id=&quot;line14&quot;&gt;&amp;lt;&lt;span class=&quot;start-tag&quot;&gt;link&lt;/span&gt;&lt;span class=&quot;attribute-name&quot;&gt; rel&lt;/span&gt;=&lt;span class=&quot;attribute-value&quot;&gt;&quot;canonical&quot;  &lt;/span&gt;&lt;span class=&quot;attribute-name&quot;&gt;href&lt;/span&gt;=&quot;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;; white-space: normal;&quot;&gt;http://www.mydomain.com/myfolder&lt;/span&gt;&quot; &lt;span class=&quot;error&quot;&gt;&lt;span class=&quot;attribute-name&quot;&gt;/&lt;/span&gt;&lt;/span&gt;&amp;gt; i.e. without the &quot;/&quot; at the end.&lt;/pre&gt;&lt;pre id=&quot;line14&quot;&gt;&lt;/pre&gt;&lt;pre id=&quot;line14&quot;&gt;This made it having different counts for share and LIKE button.&lt;/pre&gt;&lt;pre id=&quot;line14&quot;&gt;In my personal opinion it is a bug on facebook but.....&lt;/pre&gt;&lt;pre id=&quot;line14&quot;&gt;Happy coding...:)&lt;/pre&gt;&lt;pre id=&quot;line14&quot;&gt;&lt;/pre&gt;&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnettweaks.blogspot.com/feeds/3941645031321473577/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dotnettweaks.blogspot.com/2011/04/facebook-like-and-share-count-same-work.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/3941645031321473577'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/3941645031321473577'/><link rel='alternate' type='text/html' href='http://dotnettweaks.blogspot.com/2011/04/facebook-like-and-share-count-same-work.html' title='Facebook &quot;Like&quot; and &quot;Share&quot; count same -- A work around'/><author><name>Mujtaba</name><uri>http://www.blogger.com/profile/06265469390379198539</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE7MZXipftm-BTXUxPmbaYvn5g-7HIyk3BPOC5IxN1McuDMCpc5kwT71NKfWoUBwgJShN-tKRCwmLU0rmfAwOesOkWYkmgVdu07RgHB-puPuIpKvYCBeUdX-g_hTk/s220/IMG_20160315_153740-s.jpg'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8418220492622156049.post-7056987502617313121</id><published>2010-07-28T06:09:00.000-07:00</published><updated>2010-07-28T06:47:18.828-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="ASP.Net"/><category scheme="http://www.blogger.com/atom/ns#" term="javascript"/><category scheme="http://www.blogger.com/atom/ns#" term="maximum length"/><category scheme="http://www.blogger.com/atom/ns#" term="textarea"/><title type='text'>ASP.Net: Maximum length of textarea (Multiline textbox)</title><content type='html'>In ASP.Net if we use textbox with&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;TextMode=&quot;MultiLine&quot; &lt;/span&gt;then its&amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;MaxLength&lt;/span&gt; property does not work. There is a simple workaround for it using javascript.&lt;br /&gt;
&lt;br /&gt;
First dd the javascript function. This will restrict the textbox to maximum of 10 characters. As the user start typing the 11th character it will remove the 11th character immediately.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;lt;script type=&quot;text/javascript&quot;&amp;gt;&amp;nbsp;&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;function CheckMaxLength(txtBoxVal) {&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (txtBoxVal.value.length &amp;gt; 10) {&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;txtBoxVal.value = txtBoxVal.value.substring(0, 10);&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/blockquote&gt;&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;
&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;lt;/script&amp;gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;
Then add the function to&amp;nbsp;onkeyup event of textbox. (Intellisence will not show onkeyup event in visual studio you have to type it yourself)&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;lt;asp:TextBox ID=&quot;txtName&quot; TextMode=&quot;MultiLine&quot;&amp;nbsp;Height=&quot;50px&quot; runat=&quot;server&quot; Rows=&quot;3&quot; &amp;nbsp;onkeyup=&quot;CheckMaxLength(this);&quot; &amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;/span&gt;&lt;/blockquote&gt;Enjoy coding.... ! :)</content><link rel='replies' type='application/atom+xml' href='http://dotnettweaks.blogspot.com/feeds/7056987502617313121/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dotnettweaks.blogspot.com/2010/07/aspnet-maximum-length-of-textarea.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/7056987502617313121'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/7056987502617313121'/><link rel='alternate' type='text/html' href='http://dotnettweaks.blogspot.com/2010/07/aspnet-maximum-length-of-textarea.html' title='ASP.Net: Maximum length of textarea (Multiline textbox)'/><author><name>Mujtaba</name><uri>http://www.blogger.com/profile/06265469390379198539</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE7MZXipftm-BTXUxPmbaYvn5g-7HIyk3BPOC5IxN1McuDMCpc5kwT71NKfWoUBwgJShN-tKRCwmLU0rmfAwOesOkWYkmgVdu07RgHB-puPuIpKvYCBeUdX-g_hTk/s220/IMG_20160315_153740-s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8418220492622156049.post-4480154456987523845</id><published>2010-07-27T23:42:00.000-07:00</published><updated>2010-07-28T06:12:05.571-07:00</updated><title type='text'>ASP.Net: Clientside Date, Double, Integer,Currency Validation</title><content type='html'>When using text field date, Double type (decimal places or different decimal characters in globalization etc) and currency validation on client-side we often use regular expression validator and try to write complex regular expressions. The easiest way to validate these data types is to use compare validator. I think it’s the most powerful and awesome control for validating data types.&lt;br /&gt;
All you have to do is to set&lt;br /&gt;
&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Operator=&quot;DataTypeCheck&quot;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;
And &lt;br /&gt;
&lt;blockquote&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Type=&quot;&amp;lt;&amp;lt;your required type here &amp;gt;&amp;gt;&amp;gt;&quot;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;
It supports following types:&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Date&lt;/li&gt;
&lt;li&gt;Currency&lt;/li&gt;
&lt;li&gt;Double&lt;/li&gt;
&lt;li&gt;Integer&lt;/li&gt;
&lt;li&gt;String&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;strong&gt;Look at the following examples:&lt;/strong&gt;&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;&lt;strong&gt;This validates the date according to current culture of the application.&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;lt;asp:TextBox ID=&quot;txtDateStart&quot; CssClass=&quot;input&quot; runat=&quot;server&quot; Width=&quot;200&quot;&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;lt;asp:CompareValidator ID=&quot;cmprValidatorDateStart&quot; ControlToValidate=&quot;txtDateStart&quot; Type=&quot;Date&quot; Display=&quot;Dynamic&quot; Operator=&quot;DataTypeCheck&quot; ErrorMessage=&quot;*Not a valid date.&quot; runat=&quot;server&quot;&amp;lt;&amp;gt;/asp:CompareValidator&amp;gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;This validates double type. The plus point of using this is that for example you set the current culture to German (which uses &quot;,&quot; as a decimal character) it also validates that correctly with no change. &lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;lt;asp:TextBox ID=&quot;txtDoubleType&quot; CssClass=&quot;input&quot; runat=&quot;server&quot; Width=&quot;200&quot;&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;lt;asp:CompareValidator ID=&quot;cmprValidatorDoubleType &quot; ControlToValidate=&quot; txtDoubleType&quot; Type=&quot;Double&quot; Display=&quot;Dynamic&quot; Operator=&quot;DataTypeCheck&quot; ErrorMessage=&quot;*Not a valid number.&quot; runat=&quot;server&quot;&amp;lt;&amp;gt;/asp:CompareValidator&amp;gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;This validates Currency&lt;/strong&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;lt;asp:TextBox ID=&quot;txtCurrencyType&quot; CssClass=&quot;input&quot; runat=&quot;server&quot; Width=&quot;200&quot;&amp;gt;&amp;lt;/asp:TextBox&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&amp;lt;asp:CompareValidator ID=&quot;cmprValidatorDoubleType &quot; ControlToValidate=&quot; txtCurrencyType&quot; Type=&quot;Currency&quot; Display=&quot;Dynamic&quot; Operator=&quot;DataTypeCheck&quot; ErrorMessage=&quot;*Not a valid amount.&quot; runat=&quot;server&quot;&amp;lt;&amp;gt;/asp:CompareValidator&amp;gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;br /&gt;
&lt;/li&gt;
&lt;/ul&gt;&lt;br /&gt;
&lt;br /&gt;
Enjoy coding....! :)</content><link rel='replies' type='application/atom+xml' href='http://dotnettweaks.blogspot.com/feeds/4480154456987523845/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dotnettweaks.blogspot.com/2010/07/when-using-text-field-date-double-type.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/4480154456987523845'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/4480154456987523845'/><link rel='alternate' type='text/html' href='http://dotnettweaks.blogspot.com/2010/07/when-using-text-field-date-double-type.html' title='ASP.Net: Clientside Date, Double, Integer,Currency Validation'/><author><name>Mujtaba</name><uri>http://www.blogger.com/profile/06265469390379198539</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE7MZXipftm-BTXUxPmbaYvn5g-7HIyk3BPOC5IxN1McuDMCpc5kwT71NKfWoUBwgJShN-tKRCwmLU0rmfAwOesOkWYkmgVdu07RgHB-puPuIpKvYCBeUdX-g_hTk/s220/IMG_20160315_153740-s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8418220492622156049.post-108189809901436983</id><published>2010-04-14T05:41:00.000-07:00</published><updated>2010-07-28T06:11:05.290-07:00</updated><title type='text'>Binding Checkbox in GridView (A work around)</title><content type='html'>I needed to bind a checkbox in gridview to a database field but to my disappointment I found that this was not easy. We could bind &quot;Text&quot; property but what if I don&#39;t want to display the value I am binding (e.g. ID of that record). Here is a work around.&lt;br /&gt;
&lt;br /&gt;
I added a hidden field next to checkbox like below.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;br /&gt;
&amp;lt;span id=&quot;spanTextBox&quot;&amp;gt;&lt;br /&gt;
&amp;lt;asp:CheckBox ID=&quot;chkItem&quot; runat=&quot;server&quot; Checked=&quot;false&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;asp:HiddenField ID=&quot;hfdID&quot; Value=&#39;&#39; runat=&quot;server&quot; /&amp;gt;&lt;br /&gt;
&amp;lt;/span&amp;gt;&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
It&#39;s easy to access this from server side but if you want the value (intOrderId in my case) in javascript on checkbox click it requires a little trick.&lt;br /&gt;
&lt;br /&gt;
I added a javascript function to each checkbox in databound event of grid.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;protected void dgvOrders_RowDataBound(object sender, GridViewRowEventArgs e)&lt;br /&gt;
{&lt;br /&gt;
if (e.Row.RowType == DataControlRowType.DataRow)&lt;br /&gt;
{&lt;br /&gt;
CheckBox chk = e.Row.FindControl(&quot;chkItem&quot;) as CheckBox;&lt;br /&gt;
chk.Attributes.Add(&quot;onclick&quot;, &quot;CheckChanged(&#39;&quot; + chk.ClientID + &quot;&#39;);&quot;);&lt;br /&gt;
}&lt;br /&gt;
}&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
Javascript function added above goes here.&lt;br /&gt;
&lt;br /&gt;
&lt;blockquote&gt;&lt;br /&gt;
function CheckChanged(id) {&lt;br /&gt;
// The line below returns the value of that hidden field we just added.&lt;br /&gt;
// So in my case I get the intOrderId value here.&lt;br /&gt;
// Note that both these controls should be in a separate container&lt;br /&gt;
// like it have added it in the span.&lt;br /&gt;
var text = document.getElementById(id).nextSibling.nextSibling.value;&lt;br /&gt;
}&lt;/blockquote&gt;&lt;br /&gt;
&lt;br /&gt;
Hope this helps you. :)&lt;br /&gt;
Enjoy coding....!</content><link rel='replies' type='application/atom+xml' href='http://dotnettweaks.blogspot.com/feeds/108189809901436983/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dotnettweaks.blogspot.com/2010/04/binding-checkbox-in-gridview-work.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/108189809901436983'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/108189809901436983'/><link rel='alternate' type='text/html' href='http://dotnettweaks.blogspot.com/2010/04/binding-checkbox-in-gridview-work.html' title='Binding Checkbox in GridView (A work around)'/><author><name>Mujtaba</name><uri>http://www.blogger.com/profile/06265469390379198539</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE7MZXipftm-BTXUxPmbaYvn5g-7HIyk3BPOC5IxN1McuDMCpc5kwT71NKfWoUBwgJShN-tKRCwmLU0rmfAwOesOkWYkmgVdu07RgHB-puPuIpKvYCBeUdX-g_hTk/s220/IMG_20160315_153740-s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8418220492622156049.post-5398221373522673835</id><published>2010-03-29T03:11:00.000-07:00</published><updated>2010-07-28T00:31:15.697-07:00</updated><title type='text'>Comma separated string in SQL Server (without cursor)</title><content type='html'>A simple example of getting a comma seperated string of values from a column in SQL server. As cursors are not recommended (they slow down the process) I am doing it without iterating through rows.&lt;br /&gt;&lt;br /&gt;Create PROCEDURE up_GetValueString&lt;br /&gt; &lt;br /&gt;AS&lt;br /&gt;BEGIN&lt;br /&gt;&lt;br /&gt;DECLARE @statusList varchar(5000)&lt;br /&gt;&lt;br /&gt;SELECT @statusList = COALESCE(@statusList + &#39;,&#39;, &#39;&#39;) + &lt;br /&gt;   CAST(unitid AS varchar(50)) &lt;br /&gt;from&lt;br /&gt;(&lt;br /&gt;select unitid from product&lt;br /&gt;) a&lt;br /&gt;&lt;br /&gt;select @statusList AS IDS&lt;br /&gt;&lt;br /&gt;END&lt;br /&gt;GO</content><link rel='replies' type='application/atom+xml' href='http://dotnettweaks.blogspot.com/feeds/5398221373522673835/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dotnettweaks.blogspot.com/2010/03/comma-separated-string-in-sql-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/5398221373522673835'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/5398221373522673835'/><link rel='alternate' type='text/html' href='http://dotnettweaks.blogspot.com/2010/03/comma-separated-string-in-sql-server.html' title='Comma separated string in SQL Server (without cursor)'/><author><name>Mujtaba</name><uri>http://www.blogger.com/profile/06265469390379198539</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE7MZXipftm-BTXUxPmbaYvn5g-7HIyk3BPOC5IxN1McuDMCpc5kwT71NKfWoUBwgJShN-tKRCwmLU0rmfAwOesOkWYkmgVdu07RgHB-puPuIpKvYCBeUdX-g_hTk/s220/IMG_20160315_153740-s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8418220492622156049.post-2343446477863088987</id><published>2010-03-10T21:04:00.000-08:00</published><updated>2010-07-28T00:31:15.709-07:00</updated><title type='text'>How to write &amp;quot;in&amp;quot; and &amp;quot;Not in&amp;quot; query in Linq?</title><content type='html'>I was writing some simple queries in LINQ and got stuck with in-clase. I need to pick all the user roles from role table which are not assigned to any user i.e. not present in UserRole table. After a little googling I found that in LINQ there is no properly defined construct for it but people use different methods to acheive the functionality. The easiest one that worked for me is as follows.&lt;br /&gt;&lt;br /&gt;I had to acheive this:&lt;br /&gt;&lt;br /&gt;select * from roles where intRoleId not in (select ID from UserRoles)&lt;br /&gt;&lt;br /&gt;In LINQ:&lt;br /&gt;&lt;br /&gt;var Roles = (from c in dc.Roles&lt;br /&gt;                             where c.intClientId == clientId&lt;br /&gt;                             &amp;&amp; (!dc.UserRoles.Any(ur =&gt; ur.intRoleId == c.ID))&lt;br /&gt;                             select c).OrderBy(o =&gt; o.vchName);&lt;br /&gt;                returnRoles = Roles.ToList();&lt;br /&gt;&lt;br /&gt;dc.UserRoles.Any() is the subquery and &quot;!&quot; sign is for &quot;not in&quot;. If you want to write simple in-clause just remove this.&lt;br /&gt;&lt;br /&gt;Cheers,</content><link rel='replies' type='application/atom+xml' href='http://dotnettweaks.blogspot.com/feeds/2343446477863088987/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dotnettweaks.blogspot.com/2010/03/how-to-write-and-in-query-in-linq.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/2343446477863088987'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/2343446477863088987'/><link rel='alternate' type='text/html' href='http://dotnettweaks.blogspot.com/2010/03/how-to-write-and-in-query-in-linq.html' title='How to write &amp;quot;in&amp;quot; and &amp;quot;Not in&amp;quot; query in Linq?'/><author><name>Mujtaba</name><uri>http://www.blogger.com/profile/06265469390379198539</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE7MZXipftm-BTXUxPmbaYvn5g-7HIyk3BPOC5IxN1McuDMCpc5kwT71NKfWoUBwgJShN-tKRCwmLU0rmfAwOesOkWYkmgVdu07RgHB-puPuIpKvYCBeUdX-g_hTk/s220/IMG_20160315_153740-s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8418220492622156049.post-5979988272656418537</id><published>2009-12-29T23:31:00.000-08:00</published><updated>2010-07-28T00:31:15.720-07:00</updated><title type='text'>Validating all text fields.</title><content type='html'>I needed to validate all the text fields on the page and restrict the user from entering scripts into text fields and text areas. Following is the solution (Using a simple regular expression).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;This function should be called on submit of the form.&lt;br /&gt;function ValidateAllFieldsForScripting() {&lt;br /&gt;//Checking all text boxes&lt;br /&gt;    var f = document.getElementsByTagName(&#39;input&#39;);&lt;br /&gt;    var isInputValid = true;&lt;br /&gt;    for (var i = 0; i &lt; f.length; i++) {&lt;br /&gt;        if (f[i].getAttribute(&#39;type&#39;) == &#39;text&#39;) {&lt;br /&gt;            if (checkScriptInput(f[i]) == false) {&lt;br /&gt;                isInputValid = false;&lt;br /&gt;            }&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;// Checking all text areas.&lt;br /&gt;    f = document.getElementsByTagName(&#39;textarea&#39;);&lt;br /&gt;    for (var i = 0; i &lt; f.length; i++) {&lt;br /&gt;        if (checkScriptInput(f[i]) == false) {&lt;br /&gt;            isInputValid = false;&lt;br /&gt;        }&lt;br /&gt;    }&lt;br /&gt;    if (isInputValid)&lt;br /&gt;        return true;&lt;br /&gt;    else {&lt;br /&gt;        ShowInvalidInputDiv();&lt;br /&gt;        return false;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;// This function checks the text field for script input.&lt;br /&gt;function checkScriptInput(obj) {&lt;br /&gt;    var legalChars = /[\&lt;\&gt;]/;&lt;br /&gt;    if (legalChars.test(obj.value)) {&lt;br /&gt;        obj.style.background = &#39;#FFF1F5&#39;;&lt;br /&gt;        return false;&lt;br /&gt;    } else {&lt;br /&gt;        return true;&lt;br /&gt;    }&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;/// Function for displaying error message.&lt;br /&gt;function ShowInvalidInputDiv() {&lt;br /&gt;// Here you should write the code for displaying some error message to the user.&lt;br /&gt;&lt;br /&gt;}</content><link rel='replies' type='application/atom+xml' href='http://dotnettweaks.blogspot.com/feeds/5979988272656418537/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dotnettweaks.blogspot.com/2009/12/validating-all-text-fields.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/5979988272656418537'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/5979988272656418537'/><link rel='alternate' type='text/html' href='http://dotnettweaks.blogspot.com/2009/12/validating-all-text-fields.html' title='Validating all text fields.'/><author><name>Mujtaba</name><uri>http://www.blogger.com/profile/06265469390379198539</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE7MZXipftm-BTXUxPmbaYvn5g-7HIyk3BPOC5IxN1McuDMCpc5kwT71NKfWoUBwgJShN-tKRCwmLU0rmfAwOesOkWYkmgVdu07RgHB-puPuIpKvYCBeUdX-g_hTk/s220/IMG_20160315_153740-s.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8418220492622156049.post-471987599544030876</id><published>2009-03-25T02:29:00.000-07:00</published><updated>2010-07-28T00:31:15.732-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Blog groups in Community Server"/><category scheme="http://www.blogger.com/atom/ns#" term="Community Server"/><category scheme="http://www.blogger.com/atom/ns#" term="Community Server Blogs"/><category scheme="http://www.blogger.com/atom/ns#" term="Different UI of Blogs"/><title type='text'>Different user interface for different blogs in Community server.</title><content type='html'>In this post I will be guiding you how to have different user interface for different blog groups in in community server.&lt;br /&gt;&lt;br /&gt;1. Just create new blogs in different blog groups from control panel.&lt;br /&gt;&lt;br /&gt;2. Create new master pages for the blogs containing seperate CSS and structure.&lt;br /&gt;&lt;br /&gt;3. Now create a copy of &lt;strong&gt;Blogs &lt;/strong&gt;folder in Themes\[themename] folder.&lt;br /&gt;&lt;br /&gt;For example I had a folder at the following directory structure.&lt;br /&gt;Themes\hawaii\Blogs&lt;br /&gt;This folder contains pages to show blogs and blog posts. I copied it and pasted in the same folder (using visual studio 2008, I think this copy-paste would not be possible in VS 2005). Then I renamed it as &quot;MyBlogs&quot;.&lt;br /&gt;&lt;br /&gt;4. Now set you custom master page to all the pages in the new blog folder (like I have MyBlogs).&lt;br /&gt;&lt;br /&gt;5. The trick part is still not done yet. :)&lt;br /&gt;Now open your &lt;strong&gt;SiteURL.config&lt;/strong&gt; file and find &lt;strong&gt;location name=&quot;weblogs&quot;&lt;/strong&gt; section. Create a copy of all this section with all its URLs. I have almost 40 to 50 URLs in this section. Don&#39;t forget to rename all these URLs otherwise your site can give unexpected links. I renamed all these urls only by appending &quot;2&quot; with their names like the one below.&lt;br /&gt;&lt;br /&gt;&lt;textarea rows=&quot;4&quot;&gt;&lt;url name = &quot;webloghome2&quot; path=&quot;&quot; pattern =&quot;default.aspx&quot; physicalpath=&quot;##themeDir##&quot; vanity=&quot;{2}&quot; page=&quot;postlist.aspx&quot; indexable=&quot;firstpageonly&quot;&gt;&lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;By modifying you &lt;strong&gt;location&lt;/strong&gt; tag you can easily configure a URL rewriting for this folder. After this modification you are now ready to access your blogs.&lt;br /&gt;&lt;br /&gt;To filter you postlist to show posts only from a specific blog you can filter them in &lt;strong&gt;Themes\[themename]\[youblogfolder]\postlist.aspx&lt;/strong&gt;. Just open that page and give a group ID to &lt;strong&gt;weblogpostlist&lt;/strong&gt; control.&lt;br /&gt;&lt;br /&gt;For any other help required you can frankly ask here or on my email address &lt;a href=&quot;mailto:naqvi.mujtaba@gmail.com&quot;&gt;naqvi.mujtaba@gmail.com&lt;/a&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnettweaks.blogspot.com/feeds/471987599544030876/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dotnettweaks.blogspot.com/2009/03/different-user-interface-for-different.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/471987599544030876'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/471987599544030876'/><link rel='alternate' type='text/html' href='http://dotnettweaks.blogspot.com/2009/03/different-user-interface-for-different.html' title='Different user interface for different blogs in Community server.'/><author><name>Mujtaba</name><uri>http://www.blogger.com/profile/06265469390379198539</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE7MZXipftm-BTXUxPmbaYvn5g-7HIyk3BPOC5IxN1McuDMCpc5kwT71NKfWoUBwgJShN-tKRCwmLU0rmfAwOesOkWYkmgVdu07RgHB-puPuIpKvYCBeUdX-g_hTk/s220/IMG_20160315_153740-s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8418220492622156049.post-7989544223983879032</id><published>2009-03-25T01:43:00.000-07:00</published><updated>2010-07-28T00:31:15.743-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="Community Server"/><category scheme="http://www.blogger.com/atom/ns#" term="Filter posts"/><category scheme="http://www.blogger.com/atom/ns#" term="Multiple tags"/><title type='text'>How to filter posts in community server blogs using multiple tags?</title><content type='html'>In this post I will be showing you to filter posts in community server blogs page using multiple tags.&lt;br /&gt;&lt;br /&gt;The process is a lot more than simple. Following are the steps.&lt;br /&gt;&lt;br /&gt;1. Open you main blog page (Themes\[themename e.g hawii]\blogs\postlist.aspx) in any text Editor.&lt;br /&gt;&lt;br /&gt;2. Find &lt;strong&gt;weblogpostlist &lt;/strong&gt;control. There you will find &lt;strong&gt;queryoverrides &lt;/strong&gt;section. Just modify the this section and place you required tags in TAGS property (comma seperated) and then set &lt;strong&gt;LogicallyOrTags &lt;/strong&gt;property to true.&lt;br /&gt;For example I want to show only those posts on page which are tagged with &quot;MyTag1&quot; and &quot;MyTag2&quot;, I would place the following query in that section.&lt;br /&gt;&lt;br /&gt;&lt;textarea id=&quot;TextArea1&quot; name=&quot;S1&quot; rows=&quot;4&quot; cols=&quot;40&quot;&gt;&lt;queryoverrides id=&quot;pagerid&quot; isaggregate=&quot;true&quot; sortby=&quot;MostRecent&quot; tags=&quot;MyTag1,MyTag2&quot; logicallyortags=&quot;true&quot; /&gt; &lt;/textarea&gt;&lt;br /&gt;&lt;br /&gt;Now the page will show only those posts which are tagged with atleast one of these tags.&lt;br /&gt;Note: If you are changing tags of posts in Tags Editor then it takes sometime to update so you must reload page more than once.&lt;br /&gt;&lt;br /&gt;You can ask frankly if there is any dificulty. :)</content><link rel='replies' type='application/atom+xml' href='http://dotnettweaks.blogspot.com/feeds/7989544223983879032/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dotnettweaks.blogspot.com/2009/03/how-to-filter-posts-in-community-server.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/7989544223983879032'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/7989544223983879032'/><link rel='alternate' type='text/html' href='http://dotnettweaks.blogspot.com/2009/03/how-to-filter-posts-in-community-server.html' title='How to filter posts in community server blogs using multiple tags?'/><author><name>Mujtaba</name><uri>http://www.blogger.com/profile/06265469390379198539</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE7MZXipftm-BTXUxPmbaYvn5g-7HIyk3BPOC5IxN1McuDMCpc5kwT71NKfWoUBwgJShN-tKRCwmLU0rmfAwOesOkWYkmgVdu07RgHB-puPuIpKvYCBeUdX-g_hTk/s220/IMG_20160315_153740-s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8418220492622156049.post-6125171653611435417</id><published>2008-11-19T00:05:00.000-08:00</published><updated>2010-07-28T00:31:15.755-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="create web application programmatically"/><category scheme="http://www.blogger.com/atom/ns#" term="MOSS"/><category scheme="http://www.blogger.com/atom/ns#" term="MOSS 2007"/><category scheme="http://www.blogger.com/atom/ns#" term="programmatically"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint"/><category scheme="http://www.blogger.com/atom/ns#" term="Sharepoint Web Application programmatically"/><title type='text'>How to create Sharepoint Web Application Programmatically?</title><content type='html'>Sometimes we want to create Sharepoint web application programmatically (I needed it while I was writing an installer).&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;The following code will help you in this regard.&lt;/div&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;public static void Create()&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;        {&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            SPWebApplication newApplication = null;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            int port = 2020;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            string userName = &quot;xdev\\mujtaba&quot;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            string userPass = &quot;p@ssw0rd2&quot;;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            SPWebApplicationBuilder appBuilder = new SPWebApplicationBuilder(SPFarm.Local);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            int myPort = Convert.ToInt16(port.ToString());&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            appBuilder.Port = myPort;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            appBuilder.ApplicationPoolId = &quot;My Application - &quot; + port.ToString(); //Used to show in the sharepoint application list.&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            appBuilder.ApplicationPoolUsername = userName;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            System.Security.SecureString password = new System.Security.SecureString();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            char[] pass = userPass.ToCharArray();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            foreach (char c in pass)&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;                password.AppendChar(c);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            appBuilder.ApplicationPoolPassword = password;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            appBuilder.CreateNewDatabase = true; // Create new database           &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            appBuilder.DatabaseName = &quot;wss_site&quot; + port.ToString() + &quot;_content&quot;;    // database name&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            //webAppBuilder.DatabaseServer = webAppBuilder.DefaultZoneUri.Host;  //Host name/computer name          &lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            appBuilder.UseNTLMExclusively = true;  // Use NTLM authentication&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            appBuilder.ServerComment = &quot;My Application - &quot; + port.ToString();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            newApplication = appBuilder.Create(); // Create new web application&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            newApplication.Name = &quot;My Application - &quot; + port.ToString();&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            newApplication.Provision();           //Provision it into web farm&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;            Console.WriteLine(&quot;Application Successfully created.&quot;);&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;        }&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: rgb(51, 51, 255);&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;You will have to add reference to Microsoft.Sharepoint.dll to you project.&lt;/div&gt;&lt;div&gt;Enjoy it.&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnettweaks.blogspot.com/feeds/6125171653611435417/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dotnettweaks.blogspot.com/2008/11/how-to-create-sharepoint-web.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/6125171653611435417'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/6125171653611435417'/><link rel='alternate' type='text/html' href='http://dotnettweaks.blogspot.com/2008/11/how-to-create-sharepoint-web.html' title='How to create Sharepoint Web Application Programmatically?'/><author><name>Mujtaba</name><uri>http://www.blogger.com/profile/06265469390379198539</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE7MZXipftm-BTXUxPmbaYvn5g-7HIyk3BPOC5IxN1McuDMCpc5kwT71NKfWoUBwgJShN-tKRCwmLU0rmfAwOesOkWYkmgVdu07RgHB-puPuIpKvYCBeUdX-g_hTk/s220/IMG_20160315_153740-s.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8418220492622156049.post-4423704149044816437</id><published>2008-11-18T20:51:00.000-08:00</published><updated>2010-07-28T00:31:15.768-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C# SQL SERVER NETWORK INSTANCE"/><category scheme="http://www.blogger.com/atom/ns#" term="Network Instance programmatically"/><category scheme="http://www.blogger.com/atom/ns#" term="programmatically"/><category scheme="http://www.blogger.com/atom/ns#" term="SQL Server"/><title type='text'>SQL Server Network Instance Detector</title><content type='html'>&lt;span id=&quot;ArticleContent&quot;&gt;&lt;div&gt;&lt;br /&gt;&lt;/div&gt;&lt;h2&gt;What is it?&lt;/h2&gt;&lt;br /&gt;&lt;img height=&quot;220&quot; alt=&quot;Screenshot - MainImage.jpg&quot; src=&quot;http://www.codeproject.com/KB/database/NetworkInstanceDetector/MainImage.jpg&quot; width=&quot;388&quot; /&gt;&lt;br /&gt;&lt;p&gt;Control used in a sample application&lt;/p&gt;&lt;br /&gt;&lt;img height=&quot;255&quot; alt=&quot;Screenshot - Password.jpg&quot; src=&quot;http://www.codeproject.com/KB/database/NetworkInstanceDetector/Password.jpg&quot; width=&quot;393&quot; /&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;You have to give a username and password to retrieve all hosted databases. Note: &lt;em&gt;SQL_Detect_dll.zip&lt;/em&gt; is the assembly containing the &lt;code&gt;SQLServersDetector&lt;/code&gt; control. &lt;em&gt;SQL_Detect_source.zip&lt;/em&gt; contains the source code of the control, along with a sample application using the control.&lt;/p&gt;&lt;br /&gt;&lt;br /&gt;&lt;h2&gt;Introduction&lt;/h2&gt;&lt;br /&gt;&lt;br /&gt;&lt;p&gt;It&#39;s a simple window control that can load all of the SQL Server instances in your local network and then load all of the databases on the selected server. I used &lt;code&gt;SqlDataSourceEnumerator&lt;/code&gt; to load servers from the network.&lt;/p&gt;&lt;h2&gt;Background&lt;/h2&gt;&lt;p&gt;I was writing code in C# that was related to the manipulation of data with more than one database. I found that it was difficult for a user to type the address of a server and database into the text input fields and then connect to them for further manipulation because there is always the chance of the sever name or path being misspelled. If a user by mistake inputs the wrong spelling of the server or database name and then clicks connect, it takes a long time to decide that the path is not valid and throw an exception. Then the user has to to check the spelling again and give the input again, which I think is always irritating. So, I decided to detect the server instances automatically and load databases from the server and so on...&lt;/p&gt;&lt;h2&gt;Using the Control&lt;/h2&gt;&lt;p&gt;The control is easy to use, as is any other Windows control in .NET. You just have to add a reference of the DLL that is provided with this article. Alternatively, add the project to your solution and add a reference of the project &lt;code&gt;SqlServersDetector&lt;/code&gt; to your project. Then the control will appear in your Toolbox just like this.&lt;/p&gt;&lt;br /&gt;&lt;img height=&quot;214&quot; alt=&quot;Screenshot - Toolbox.jpg&quot; src=&quot;http://www.codeproject.com/KB/database/NetworkInstanceDetector/Toolbox.jpg&quot; width=&quot;356&quot; /&gt;&lt;br /&gt;&lt;p&gt;Now you can simply drag and drop it onto your form.&lt;/p&gt;&lt;h2&gt;Properties of the Control&lt;/h2&gt;&lt;p&gt;You can use the following properties of the control if you need them.&lt;/p&gt;&lt;pre lang=&quot;cs&quot;&gt;//Property to get the connection string that is created&lt;br /&gt;&lt;br /&gt;//by using selected server, selected database, username and password.&lt;br /&gt;&lt;br /&gt;lblConnectionString.Text = sqlServersDetector1.DBConnectionString;&lt;br /&gt;&lt;br /&gt;//Property to get or set the text that is displayed on&lt;br /&gt;&lt;br /&gt;//upper left corner of the control&lt;br /&gt;&lt;br /&gt;sqlServersDetector1.MainLabel = &quot;All Servers&quot;;&lt;br /&gt;&lt;br /&gt;//Property to get or set the text that of the label&lt;br /&gt;&lt;br /&gt;//against Servers combo box.&lt;br /&gt;&lt;br /&gt;sqlServersDetector1.ServersLabel = &quot;Servers&quot;;&lt;br /&gt;&lt;br /&gt;//Property to get or set the text that of the label&lt;br /&gt;&lt;br /&gt;//against Databases combo box.&lt;br /&gt;&lt;br /&gt;sqlServersDetector1.DatabasesLabel = &quot;Database&quot;;&lt;br /&gt;&lt;br /&gt;//Property to get the selected server instance.&lt;br /&gt;&lt;br /&gt;string server = sqlServersDetector1.SelectedServer;&lt;br /&gt;&lt;br /&gt;//Property to get the selected database.&lt;br /&gt;&lt;br /&gt;string database = sqlServersDetector1.SelectedDatabase;&lt;/pre&gt;&lt;h2&gt;Using the Example Solution Provided with the Article&lt;/h2&gt;&lt;p&gt;If any beginner doesn&#39;t know how to use the solution, just download the ZIP file &lt;em&gt;SQL_Detect_source.zip&lt;/em&gt; and unzip it. Then open the &lt;em&gt;SQLServerDetectionControl.sln&lt;/em&gt; solution file and run the project named &lt;code&gt;TestAppForSQLServerControl&lt;/code&gt;. If you are still facing problems using this control, then feel free to ask.&lt;span class=&quot;Apple-style-span&quot;  style=&quot; ;font-size:48px;&quot;&gt;&lt;a href=&quot;http://www.codeproject.com/KB/database/NetworkInstanceDetector/SQL_Detect_dll.zip&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot; ;font-size:16px;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot; &quot;&gt;&lt;a href=&quot;http://www.codeproject.com/KB/database/NetworkInstanceDetector/SQL_Detect_dll.zip&quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt;Download control DLL - 4.7 KB&lt;/span&gt;&lt;/a&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt;&lt;a href=&quot;http://www.codeproject.com/KB/database/NetworkInstanceDetector/SQL_Detect_source.zip&quot;&gt;&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot; &quot;&gt;&lt;span class=&quot;Apple-style-span&quot;  style=&quot;font-size:medium;&quot;&gt;&lt;a href=&quot;http://www.codeproject.com/KB/database/NetworkInstanceDetector/SQL_Detect_source.zip&quot;&gt;Download source - 31.8 KB&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;This article is also available on codeproject on the following link.&lt;/p&gt;&lt;p&gt;&lt;a href=&quot;http://www.codeproject.com/KB/database/NetworkInstanceDetector.aspx&quot;&gt;http://www.codeproject.com/KB/database/NetworkInstanceDetector.aspx&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnettweaks.blogspot.com/feeds/4423704149044816437/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dotnettweaks.blogspot.com/2008/11/sql-server-network-instance-detector.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/4423704149044816437'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/4423704149044816437'/><link rel='alternate' type='text/html' href='http://dotnettweaks.blogspot.com/2008/11/sql-server-network-instance-detector.html' title='SQL Server Network Instance Detector'/><author><name>Mujtaba</name><uri>http://www.blogger.com/profile/06265469390379198539</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE7MZXipftm-BTXUxPmbaYvn5g-7HIyk3BPOC5IxN1McuDMCpc5kwT71NKfWoUBwgJShN-tKRCwmLU0rmfAwOesOkWYkmgVdu07RgHB-puPuIpKvYCBeUdX-g_hTk/s220/IMG_20160315_153740-s.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-8418220492622156049.post-8015187477773536497</id><published>2008-11-18T04:12:00.000-08:00</published><updated>2010-07-28T00:31:15.777-07:00</updated><title type='text'>About this Blog</title><content type='html'>&lt;span class=&quot;Apple-style-span&quot; style=&quot;border-collapse: separate; color: rgb(0, 0, 0); font-family: &#39;Times New Roman&#39;; font-size: 16px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px;&quot;&gt;&lt;div style=&quot;border-width: 0px; margin: 0px; padding: 3px; width: auto; font-family: Georgia,serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; text-align: left;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;font-family: &#39;Times New Roman&#39;;&quot;&gt;&lt;div style=&quot;border-width: 0px; margin: 0px; padding: 3px; width: auto; font-family: Georgia,serif; font-style: normal; font-variant: normal; font-weight: normal; font-size: 100%; line-height: normal; font-size-adjust: none; font-stretch: normal; text-align: left;&quot;&gt;You can find some useful information on this blog about Microsoft Sharepoint Server 2007. You can frankly ask about confusion that you have about sharepoint server. You can also share your experiences so that others may benefit from you experience.&lt;/div&gt;&lt;/span&gt;&lt;/div&gt;&lt;/span&gt;</content><link rel='replies' type='application/atom+xml' href='http://dotnettweaks.blogspot.com/feeds/8015187477773536497/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://dotnettweaks.blogspot.com/2008/11/about-this-blog.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/8015187477773536497'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/8418220492622156049/posts/default/8015187477773536497'/><link rel='alternate' type='text/html' href='http://dotnettweaks.blogspot.com/2008/11/about-this-blog.html' title='About this Blog'/><author><name>Mujtaba</name><uri>http://www.blogger.com/profile/06265469390379198539</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='28' height='32' src='//blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjE7MZXipftm-BTXUxPmbaYvn5g-7HIyk3BPOC5IxN1McuDMCpc5kwT71NKfWoUBwgJShN-tKRCwmLU0rmfAwOesOkWYkmgVdu07RgHB-puPuIpKvYCBeUdX-g_hTk/s220/IMG_20160315_153740-s.jpg'/></author><thr:total>0</thr:total></entry></feed>