<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>GvsRadhika's Weblog</title>
	<atom:link href="http://gvsradhika.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://gvsradhika.wordpress.com</link>
	<description>Just another WordPress.com weblog</description>
	<lastBuildDate>Tue, 18 Nov 2008 04:42:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='gvsradhika.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>GvsRadhika's Weblog</title>
		<link>http://gvsradhika.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://gvsradhika.wordpress.com/osd.xml" title="GvsRadhika&#039;s Weblog" />
	<atom:link rel='hub' href='http://gvsradhika.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Pass Credentials to a Web Service that Uses Basic Authentication?</title>
		<link>http://gvsradhika.wordpress.com/2008/08/05/pass-credentials-to-a-web-service-that-uses-basic-authentication/</link>
		<comments>http://gvsradhika.wordpress.com/2008/08/05/pass-credentials-to-a-web-service-that-uses-basic-authentication/#comments</comments>
		<pubDate>Tue, 05 Aug 2008 04:39:28 +0000</pubDate>
		<dc:creator>gvsradhika</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gvsradhika.wordpress.com/?p=32</guid>
		<description><![CDATA[When you&#8217;re working with Web Services that require authentication, you&#8217;ll need a way to pass credentials. This snippet shows you how to pass a user name and password to a Web Service that is configured for Basic Authentication. using System.Net; &#8230;. localhost.MyWebService myService = new localhost.MyWebService(); System.Net.CredentialCache myCredentials = new System.Net.CredentialCache(); NetworkCredential netCred = new [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gvsradhika.wordpress.com&amp;blog=3053177&amp;post=32&amp;subd=gvsradhika&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>When you&#8217;re working with Web Services that require authentication, you&#8217;ll need a way to pass credentials. This snippet shows you how to pass a user name and password to a Web Service that is configured for Basic Authentication.<br />
using System.Net;</p>
<p>&#8230;.</p>
<p>localhost.MyWebService myService = new localhost.MyWebService();</p>
<p>System.Net.CredentialCache myCredentials = new System.Net.CredentialCache();<br />
NetworkCredential netCred = new NetworkCredential(&#8220;UserName&#8221;, &#8220;Password&#8221;);<br />
myCredentials.Add(new Uri(myService.Url), &#8220;Basic&#8221;, netCred);<br />
myService.Credentials = myCredentials;</p>
<p>// Now call methods on the myService object&#8230;.</p>
<p>You should be aware that by using Basic Authentication the user name and password are sent as Base 64 encoded text. That is as secure as sending it as plain text, so the best way to use this authentication mechanism is in combination with SSL. This way, the data is encrypted and is save from prying eyes&#8230;.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gvsradhika.wordpress.com/32/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gvsradhika.wordpress.com/32/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gvsradhika.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gvsradhika.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gvsradhika.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gvsradhika.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gvsradhika.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gvsradhika.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gvsradhika.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gvsradhika.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gvsradhika.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gvsradhika.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gvsradhika.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gvsradhika.wordpress.com/32/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gvsradhika.wordpress.com/32/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gvsradhika.wordpress.com/32/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gvsradhika.wordpress.com&amp;blog=3053177&amp;post=32&amp;subd=gvsradhika&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gvsradhika.wordpress.com/2008/08/05/pass-credentials-to-a-web-service-that-uses-basic-authentication/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/951b10b49131c5b496c961e87d283d6e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gvsradhika</media:title>
		</media:content>
	</item>
		<item>
		<title>Storing and Retrieving Image in SQL Server</title>
		<link>http://gvsradhika.wordpress.com/2008/07/25/storing-and-retrieving-image-in-sql-server/</link>
		<comments>http://gvsradhika.wordpress.com/2008/07/25/storing-and-retrieving-image-in-sql-server/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 06:45:47 +0000</pubDate>
		<dc:creator>gvsradhika</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gvsradhika.wordpress.com/?p=26</guid>
		<description><![CDATA[Hi, I saw many developers are asking this questions in different forums. Recently I saw this question on MSDN forum and I thought let me write a blog on this. I know many of us found this too easy however for new bees its bit hard. In this article, I had used SQL Server 2005 [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gvsradhika.wordpress.com&amp;blog=3053177&amp;post=26&amp;subd=gvsradhika&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Hi, I saw many developers are asking this questions in different forums. Recently I saw this question on MSDN forum and I thought let me write a blog on this. I know many of us found this too easy however for new bees its bit hard.</p>
<p>In this article, I had used SQL Server 2005 as back end and C# as front end. SQL Server has “Image” data type to store the image. In Oracle and some other database you can use a data type which is used to store binary value (may be BLOB). I have created a simple aspx which has File upload control and a button. When user selects a file to upload, I am checking it for valid image type and converting it to array of Bytes. Then I will store that byte array into database. Below is the code,</p>
<p>if (objFileUpload.PostedFile !=null)<br />
{<br />
if (objFileUpload.PostedFile.ContentLength &gt; 0)<br />
{<br />
// Get Posted File.<br />
HttpPostedFile objHttpPostedFile = objFileUpload.PostedFile;</p>
<p>// Check valid Image type. Create this function according to your need<br />
if (CheckValidFileType(objHttpPostedFile.FileName))<br />
{<br />
// Find its length and convert it to byte array<br />
int intContentlength = objHttpPostedFile.ContentLength;</p>
<p>// Create Byte Array<br />
Byte[] bytImage =new Byte[intContentlength];</p>
<p>// Read Uploaded file in Byte Array<br />
objHttpPostedFile.InputStream.Read(bytImage, 0,<br />
intContentlength);</p>
<p>}<br />
}</p>
<p>}</p>
<p>Fig &#8211;  (1)  Read Uploaded file (here Image) in Byte Array</p>
<p>Pass this Byte array to you DAL and use it for storing image in database. I am using Enterprise Library as DAL so my code will look like,</p>
<p>Database db =DatabaseFactory.CreateDatabase();</p>
<p>string sqlCommand =“StoredProcedureName”;</p>
<p>DbCommand dbCommandWrapper = db.GetStoredProcCommand(sqlCommand);</p>
<p>db.AddInParameter(dbCommandWrapper,“@Image”,DbType.Binary,<br />
bytImage );</p>
<p>try<br />
{<br />
db.ExecuteNonQuery(dbCommandWrapper);<br />
}<br />
catch {throw; }</p>
<p>Fig &#8211;  (2)  Insert Image in to database</p>
<p>This is how you can store the Image in database. Retrieving the image is the same process. Write a SP which will return your image. Store this value in a Byte Array. Once you get the image in Byte array, you just have to write it on form as shown below,</p>
<p>Byte[] bytImage =Byte array retrieved from database.<br />
if (bytImage !=null)<br />
{<br />
Response.ContentType =“image/jpeg”;<br />
Response.Expires = 0; Response.Buffer =true;<br />
Response.Clear();<br />
Response.BinaryWrite(bytImage);<br />
Response.End();<br />
}</p>
<p>Fig &#8211;  (3)  Code to display Byte array as Image on form.</p>
<p>To use this at multiple places in your application, you create a page to which you can pass ID of Image and it will retrieve image from database and create image. To do this copy paste above code in aspx.cs file. Now on every page you require to show this image  take &lt;asp:Image&gt; on that page and set its ImageURL property to the path of newly created user control. See the code below,<br />
&lt;asp:Image ID=”ViewImage” runat=”server” /&gt;</p>
<p>Fig &#8211;  (4) Image control on any aspx page (Lets say Sample.aspx).</p>
<p>string strURL =“~/ViewImage.aspx?ID= 1 “ ;<br />
ViewImage.ImageUrl = strURL;<br />
Happy Programing.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gvsradhika.wordpress.com/26/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gvsradhika.wordpress.com/26/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gvsradhika.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gvsradhika.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gvsradhika.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gvsradhika.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gvsradhika.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gvsradhika.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gvsradhika.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gvsradhika.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gvsradhika.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gvsradhika.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gvsradhika.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gvsradhika.wordpress.com/26/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gvsradhika.wordpress.com/26/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gvsradhika.wordpress.com/26/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gvsradhika.wordpress.com&amp;blog=3053177&amp;post=26&amp;subd=gvsradhika&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gvsradhika.wordpress.com/2008/07/25/storing-and-retrieving-image-in-sql-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/951b10b49131c5b496c961e87d283d6e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gvsradhika</media:title>
		</media:content>
	</item>
		<item>
		<title>Maintaining State of CheckBoxes While Paging in a GridView Control</title>
		<link>http://gvsradhika.wordpress.com/2008/07/25/maintaining-state-of-checkboxes-while-paging-in-a-gridview-control/</link>
		<comments>http://gvsradhika.wordpress.com/2008/07/25/maintaining-state-of-checkboxes-while-paging-in-a-gridview-control/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 06:20:27 +0000</pubDate>
		<dc:creator>gvsradhika</dc:creator>
				<category><![CDATA[.NET 3.5]]></category>

		<guid isPermaLink="false">http://gvsradhika.wordpress.com/?p=16</guid>
		<description><![CDATA[Abstract In this article, I will demonstrate how you can maintain the state of CheckBoxes while paging in a GridView control. Creating the GridView Control Checkbox selection inside the GridView control with no paging can be accomplished by writing a few lines of code. In this article, I will demonstrate how you can maintain the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gvsradhika.wordpress.com&amp;blog=3053177&amp;post=16&amp;subd=gvsradhika&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Abstract<br />
In this article, I will demonstrate how you can maintain the state of CheckBoxes while paging in a GridView control.</p>
<p>Creating the GridView Control</p>
<p>Checkbox selection inside the GridView control with no paging can be accomplished by writing a few lines of code. In this article, I will demonstrate how you can maintain the state of the CheckBoxes that are present inside the GridView with paging enabled.</p>
<p>The first thing you need to do is to create the GridView control. This can be done simply by dragging and dropping the GridView from the Toolbox onto the web form. Once you have the GridView, you can edit its columns using the smart tag or the HTML view of the page. I will add two bound columns and one template column. The bound columns &#8220;CategoryID&#8221; and &#8220;CategoryName&#8221; will be bound to the database fields &#8220;CategoryID&#8221; and &#8220;CategoryName&#8221; respectively. The template column will be used to display the CheckBoxes in the GridView control.</p>
<p>After adding the columns, the html source of the GridView control looks like this.</p>
<p>Listing 1: GridView HTML Code</p>
<p>AutoGenerateColumns=&#8221;False&#8221; AllowPaging=&#8221;True&#8221;<br />
PageSize=&#8221;5&#8243; Width=&#8221;324px&#8221; DataKeyNames=&#8221;CategoryID&#8221;<br />
OnPageIndexChanging=&#8221;GridView1_PageIndexChanging&#8221;&gt;<br />
Please also note that the paging is enabled in the GridView control, and the DataKeyNames property has been set to &#8220;CategoryID,&#8221; since it’s the primary key in the database. The PageSize property has been set to 5, which means that after one page of the GridView can only contain 5 records/rows. The ItemTemplate tag contains the CheckBox whose ID is &#8220;CheckBox1,&#8221; which means that CheckBoxes will be displayed for the last column.</p>
<p>Populating the GridView Control</p>
<p>Let’s first see how I am populating the GridView control. I have defined a query as a private string constant, which is shown below.</p>
<p>Listing 2: Query to Retrieve Information from the Categories Table</p>
<p>/* QUERY */<br />
private const string QUERY_SELECT_ALL_CATEGORIES = &#8220;SELECT * FROM Categories&#8221;;</p>
<p>The above query is used in the BindData method, which simply populates the GridView control with the DataSet object.</p>
<p>Listing 3: BindData Method to Populate the GridView Control</p>
<p>private void BindData()<br />
{<br />
SqlConnection myConnection = new SqlConnection(ConnectionString);<br />
SqlDataAdapter ad = new SqlDataAdapter(QUERY_SELECT_ALL_CATEGORIES,<br />
myConnection);<br />
DataSet ds = new DataSet();<br />
ad.Fill(ds, &#8220;Categories&#8221;);<br />
GridView1.DataSource = ds;<br />
GridView1.DataBind();<br />
}</p>
<p>Remember Checked Values</p>
<p>The application will work fine if the number of pages is less than the page size. As soon as the paging kicks in, the GridView control will forget all the checked values of the old pages. You need some mechanism to store the previously checked values of the CheckBoxes. Fortunately, the Session variable can be used to store the checked values between postbacks.</p>
<p>Below, I have created a method, RememberOldValues, which iterates through the GridView rows and finds which values are checked. Once it gets the checked value, it stores the primary key of the table inside the Session object.</p>
<p>Listing 4: Save Checked Values</p>
<p>private void RememberOldValues()<br />
{<br />
ArrayList categoryIDList = new ArrayList();<br />
int index = -1;<br />
foreach (GridViewRow row in GridView1.Rows)<br />
{<br />
index = (int) GridView1.DataKeys[row.RowIndex].Value;<br />
bool result = ((CheckBox)row.FindControl(&#8220;CheckBox1&#8243;)).Checked;</p>
<p>// Check in the Session<br />
if (Session[CHECKED_ITEMS] != null)<br />
categoryIDList = (ArrayList)Session[CHECKED_ITEMS];<br />
if (result)<br />
{<br />
if (!categoryIDList.Contains(index))<br />
categoryIDList.Add(index);<br />
}<br />
else<br />
categoryIDList.Remove(index);<br />
}<br />
if (categoryIDList != null &amp;&amp; categoryIDList.Count &gt; 0)<br />
Session[CHECKED_ITEMS] = categoryIDList;<br />
}</p>
<p>Analysis</p>
<p>The first thing I did is to make an object of the ArrayList so that I can store the primary keys in it. You will need to include the System.Collections namespace in order to work with an ArrayList. After that, I loop through the GridView rows, checking to see which CheckBox is checked. Once I find the CheckBox that is checked, I insert the primary key, which in this case is &#8220;CategoryID,&#8221; into the ArrayList. If the row is not checked, I get the &#8220;CategoryID&#8221; and remove it from the ArrayList. If the ArrayList is not null, then I put the ArrayList inside the Session object.</p>
<p>Re-Populate CheckBoxes</p>
<p>In the last method, RememberOldValues, we captured and saved the primary keys of all the rows that were checked. In the RePopulateValues method, we will retrieve the saved values and assign them to the CheckBoxes.</p>
<p>Listing 5: Re-Populate CheckBoxes</p>
<p>private void RePopulateValues()<br />
{<br />
ArrayList categoryIDList = (ArrayList)Session[CHECKED_ITEMS];<br />
if (categoryIDList != null &amp;&amp; categoryIDList.Count &gt; 0)<br />
{<br />
foreach (GridViewRow row in GridView1.Rows)<br />
{<br />
int index = (int)GridView1.DataKeys[row.RowIndex].Value;<br />
if (categoryIDList.Contains(index))<br />
{<br />
CheckBox myCheckBox = (CheckBox) row.FindControl(&#8220;CheckBox1&#8243;);<br />
myCheckBox.Checked = true;<br />
}<br />
}<br />
}<br />
}</p>
<p>Analysis</p>
<p>The RePopulateValues method is quite simple. All we do is retrieve the ArrayList that is stored inside the Session object. After checking that the ArrayList is not null and contains some items, we iterate through the GridView control row by row. If the ArrayList contains the primary key of the row, then it means that row should have its CheckBox in a checked state. This is done by using the Contains method of the ArrayList. If the ArrayList contains the primary key, then we extract the control using the row.FindControl method and assign its checked property to true.</p>
<p>Implementing GridView Page_IndexChangingEvent</p>
<p>The last thing that we need to implement is the Page_IndexChangingEvent of the GridView control. Page_IndexChangingEvent is fired whenever paging occurs. The implementation of this method is given below.</p>
<p>Listing 6: GridView Page_IndexChanging Event</p>
<p>protected void GridView1_PageIndexChanging(object sender, GridViewPageEventArgs e)<br />
{<br />
RememberOldValues();<br />
GridView1.PageIndex = e.NewPageIndex;<br />
BindData();<br />
RePopulateValues();<br />
}</p>
<p>Analysis</p>
<p>The above method first calls RememberOldValues so that all primary keys of the checked CheckBoxes will be saved in a Session object. Next ,the page goes to the new GridView page, and finally, we populate the CheckBoxes using the RePopulateValues method.</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gvsradhika.wordpress.com/16/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gvsradhika.wordpress.com/16/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gvsradhika.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gvsradhika.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gvsradhika.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gvsradhika.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gvsradhika.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gvsradhika.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gvsradhika.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gvsradhika.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gvsradhika.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gvsradhika.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gvsradhika.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gvsradhika.wordpress.com/16/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gvsradhika.wordpress.com/16/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gvsradhika.wordpress.com/16/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gvsradhika.wordpress.com&amp;blog=3053177&amp;post=16&amp;subd=gvsradhika&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gvsradhika.wordpress.com/2008/07/25/maintaining-state-of-checkboxes-while-paging-in-a-gridview-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/951b10b49131c5b496c961e87d283d6e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gvsradhika</media:title>
		</media:content>
	</item>
		<item>
		<title>C# Code to Upload a file through ftp</title>
		<link>http://gvsradhika.wordpress.com/2008/07/25/c-code-to-upload-a-file-through-ftp/</link>
		<comments>http://gvsradhika.wordpress.com/2008/07/25/c-code-to-upload-a-file-through-ftp/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 06:18:10 +0000</pubDate>
		<dc:creator>gvsradhika</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gvsradhika.wordpress.com/?p=14</guid>
		<description><![CDATA[C# Code to Upload a file through ftp Here I am giving the code to access ftp server thruogh your .net applcation. The code works on both windows as well as web. You can upload a file through ftp and make your own ftp client by researching more on this top. System.Net.FtpWebRequest ftpClient=System.Net.FtpWebRequest.Create(&#8220;ftp://Yoursite.com/yourdirectory/&#8221;+&#8221;Filename&#8221;); ftpClient.Credentials = [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gvsradhika.wordpress.com&amp;blog=3053177&amp;post=14&amp;subd=gvsradhika&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>C# Code to Upload a file through ftp<br />
Here I am giving the code to access ftp server thruogh your .net applcation. The code works on both windows as well as web. You can upload a file through ftp and make your own ftp client by researching more on this top.</p>
<p>System.Net.FtpWebRequest ftpClient=System.Net.FtpWebRequest.Create(&#8220;ftp://Yoursite.com/yourdirectory/&#8221;+&#8221;Filename&#8221;);<br />
ftpClient.Credentials = new System.Net.NetworkCredential(&#8220;loginname&#8221;, &#8220;password&#8221;);<br />
ftpClient.Method=System.Net.WebRequestMethods.Ftp.UploadFile;<br />
ftpClient.UseBinary=true;<br />
System.IO.FileInfo fi= new System.IO.FileInfo(&#8220;Local FilePath to be Uploaded&#8221;);<br />
ftpClient.ContentLength=fi.Length;<br />
int bufferSize=2048;<br />
byte[] content= new byte[bufferSize-1];<br />
int dataread;<br />
System.IO.FileStream fs=fi.OpenRead();<br />
try<br />
{<br />
}<br />
catch (Exception ex)<br />
{<br />
System.IO.Stream rs=ftpClient.GetRequestStream();<br />
do{<br />
dataread=fs.Read(content,0,bufferSize);<br />
rs.Write(content,0,dataread);<br />
}while(dataread}</p>
<p>finally<br />
{<br />
fs.Close();<br />
}</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gvsradhika.wordpress.com/14/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gvsradhika.wordpress.com/14/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gvsradhika.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gvsradhika.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gvsradhika.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gvsradhika.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gvsradhika.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gvsradhika.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gvsradhika.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gvsradhika.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gvsradhika.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gvsradhika.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gvsradhika.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gvsradhika.wordpress.com/14/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gvsradhika.wordpress.com/14/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gvsradhika.wordpress.com/14/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gvsradhika.wordpress.com&amp;blog=3053177&amp;post=14&amp;subd=gvsradhika&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gvsradhika.wordpress.com/2008/07/25/c-code-to-upload-a-file-through-ftp/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/951b10b49131c5b496c961e87d283d6e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gvsradhika</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating Thumbnail of an Image with maintained aspect ratio in C #.NET</title>
		<link>http://gvsradhika.wordpress.com/2008/07/25/creating-thumbnail-of-an-image-with-maintained-aspect-ratio-in-c-net/</link>
		<comments>http://gvsradhika.wordpress.com/2008/07/25/creating-thumbnail-of-an-image-with-maintained-aspect-ratio-in-c-net/#comments</comments>
		<pubDate>Fri, 25 Jul 2008 06:17:17 +0000</pubDate>
		<dc:creator>gvsradhika</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gvsradhika.wordpress.com/?p=12</guid>
		<description><![CDATA[For creating thumnail images C# has function in System.Drawing in namespace. System.Drawing.Image class contains GetThubnailImage function which creates thumbnail of an image but use this function wisely to create thubnail which maintains the aspect ratio of image thumbnai. Below is the C# function which creates the thumbnail of an image with maintained aspect ratio. public [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gvsradhika.wordpress.com&amp;blog=3053177&amp;post=12&amp;subd=gvsradhika&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>For creating thumnail images C# has function in System.Drawing in namespace. System.Drawing.Image class contains GetThubnailImage function which creates thumbnail of an image but use this function wisely to create thubnail which maintains the aspect ratio of image thumbnai. Below is the C# function which creates the thumbnail of an image with maintained aspect ratio.</p>
<p>public static void Create_Thumbnails(int size, string FilePath, string ThumbPath)<br />
{// create an image object, using the filename we just retrieved<br />
System.Drawing.Image image = System.Drawing.Image.FromFile(FilePath);<br />
try{int thumbHeight, thumbWidth;<br />
decimal h = image.Height;<br />
decimal w = image.Width;<br />
if (image.Height &gt; image.Width){thumbHeight = size;<br />
decimal tWidth = (w / h) * thumbHeight;<br />
thumbWidth = Convert.ToInt32(tWidth);<br />
}<br />
else<br />
{<br />
thumbWidth = size;<br />
decimal tHeight = (h / w) * thumbWidth;<br />
thumbHeight = Convert.ToInt32(tHeight);<br />
}// create the actual thumbnail image<br />
System.Drawing.Image thumbnailImage = image.GetThumbnailImage(thumbWidth, thumbHeight, null, IntPtr.Zero);<br />
image.Dispose();// put the image into the memory stream<br />
thumbnailImage.Save(ThumbPath, System.Drawing.Imaging.ImageFormat.Jpeg);<br />
}<br />
catch (Exception ex){image.Dispose();throw ex;}<br />
}</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gvsradhika.wordpress.com/12/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gvsradhika.wordpress.com/12/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gvsradhika.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gvsradhika.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gvsradhika.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gvsradhika.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gvsradhika.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gvsradhika.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gvsradhika.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gvsradhika.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gvsradhika.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gvsradhika.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gvsradhika.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gvsradhika.wordpress.com/12/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gvsradhika.wordpress.com/12/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gvsradhika.wordpress.com/12/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gvsradhika.wordpress.com&amp;blog=3053177&amp;post=12&amp;subd=gvsradhika&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gvsradhika.wordpress.com/2008/07/25/creating-thumbnail-of-an-image-with-maintained-aspect-ratio-in-c-net/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/951b10b49131c5b496c961e87d283d6e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gvsradhika</media:title>
		</media:content>
	</item>
		<item>
		<title>Creating ASP.NET 2.0 Visio Custom Control</title>
		<link>http://gvsradhika.wordpress.com/2008/03/07/creating-aspnet-20-visio-custom-control/</link>
		<comments>http://gvsradhika.wordpress.com/2008/03/07/creating-aspnet-20-visio-custom-control/#comments</comments>
		<pubDate>Fri, 07 Mar 2008 06:34:55 +0000</pubDate>
		<dc:creator>gvsradhika</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gvsradhika.wordpress.com/?p=5</guid>
		<description><![CDATA[Introduction: This article describes a quick and simple approach to creating a custom web control used to display Microsoft Visio files within an ASP.NET page using Internet Explorer.  It is entirely possible to code the page to display a Visio diagram without using a custom control, having the control handy simplifies the process to the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gvsradhika.wordpress.com&amp;blog=3053177&amp;post=5&amp;subd=gvsradhika&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Verdana, Arial, Helvetica, sans-serif"><strong>Introduction:</strong></font></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Verdana, Arial, Helvetica, sans-serif">This article describes a quick and simple approach to creating a custom web control used to display Microsoft Visio files within an ASP.NET page using Internet Explorer.<span>  </span></font></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Verdana, Arial, Helvetica, sans-serif">It is entirely possible to code the page to display a Visio diagram without using a custom control, having the control handy simplifies the process to the point where someone using it need only drop it onto the page and set a file path property within the IDE (or at runtime) to bring the Visio diagram into the page.</font></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Verdana, Arial, Helvetica, sans-serif">Further, it is possible to open a Visio file directly into Microsoft Internet Explorer; to do this, one need only create hyperlink and set it to navigate directly to the Visio file.<span> </span>Of course Visio files may also be converted to a web page or image format and displayed as images added to a web page.<span> </span>The only advantage to using a custom control is that it allows the developer to build a page and add the Visio file to that page as content rather than to merely open the diagram as a standalone page.<span> </span>Also, if the Visio diagram is converted to an image, the image will not have the control options available (e.g., scrolling, panning, etc.) when viewing the diagram in the control.</font></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Verdana, Arial, Helvetica, sans-serif"><strong>Getting Started:</strong></font></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Verdana, Arial, Helvetica, sans-serif">In order to get started, open up the Visual Studio 2005 IDE and start a new project.<span> </span>From the new project dialog (Figure 1), under project types, select the &#8220;Windows&#8221; node from beneath &#8220;C#&#8221;, then select the &#8220;Web Control Library&#8221; template in the right hand pane.<span> </span>Key in a name for the project and then click &#8220;OK&#8221;.</font></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Verdana, Arial, Helvetica, sans-serif">Once the project has opened; right click on the solution and click on the &#8220;Add&#8221; menu option, and then select &#8220;New Item&#8221;.<span> </span>When the &#8220;Add New Item&#8221; dialog appears (Figure 2), select the &#8220;Web Custom Control&#8221; template, after selecting the template, key &#8220;<em>ShowVisio.cs</em>&#8221; into the name field and then click &#8220;Add&#8221; to close the dialog.<span> </span>You may now delete the default web control that was created<span>  </span>when the project was originally initialized from the template.</font></p>
<p><font face="Verdana, Arial, Helvetica, sans-serif">At this point, we should have an open web control library project with a single web control named &#8220;<em>ShowVisio.cs</em>&#8221; in that project.<span> </span>One last step prior to writing the code for this project will be to add in one needed reference.<span> </span>To add this reference, right click on the references folder in the solution explorer and then click on the &#8220;Add Reference&#8221; menu option.<span> </span>When the &#8220;Add Reference&#8221; dialog opens, select the .NET tab, and search down the list until you find the &#8220;<em>System.Design</em>&#8221; reference.<span> </span>Select this library and click on the &#8220;OK&#8221; button.</p>
<p></font><font face="Verdana, Arial, Helvetica, sans-serif"><strong><br />
<font face="Verdana, Arial, Helvetica, sans-serif"><strong><img border="0" align="baseline" src="http://www.c-sharpcorner.com/UploadFile/scottlysle/CC_Visio01142007140634PM/Images/Showvision1.gif" /></strong></font><br />
</strong><br />
Figure 1:<span>  </span>Visual Studio 2005 New Project Dialog</font><font face="Verdana, Arial, Helvetica, sans-serif"></p>
<p><strong><br />
<strong><img border="0" align="baseline" src="http://www.c-sharpcorner.com/UploadFile/scottlysle/CC_Visio01142007140634PM/Images/Showvision2.gif" /></strong></p>
<p></strong>Figure 2:<span> </span>Add New Item Dialog</font><b><font face="Verdana, Arial, Helvetica, sans-serif">Code:<span>  </span>Show Vision Control</font></b></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Verdana, Arial, Helvetica, sans-serif">Navigate back to the &#8220;ShowVisio.cs&#8221; file and, at the top of the file, add in the import statement highlighted below:</font></p>
<p><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:10pt;color:blue;font-family:Consolas;">using</span><span style="font-size:10pt;font-family:Consolas;"> System;</span></font><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:10pt;color:blue;font-family:Consolas;">using</span><span style="font-size:10pt;font-family:Consolas;"> System.Collections.Generic;</span></font><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:10pt;color:blue;font-family:Consolas;">using</span><span style="font-size:10pt;font-family:Consolas;"> System.ComponentModel;</span></font><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:10pt;color:blue;font-family:Consolas;">using</span><span style="font-size:10pt;font-family:Consolas;"> System.Text;</span></font><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:10pt;color:blue;font-family:Consolas;">using</span><span style="font-size:10pt;font-family:Consolas;"> System.Web;</span></font><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:10pt;color:blue;font-family:Consolas;">using</span><span style="font-size:10pt;font-family:Consolas;"> System.Web.UI;</span></font><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:10pt;color:blue;font-family:Consolas;">using</span><span style="font-size:10pt;font-family:Consolas;"> System.Web.UI.WebControls;</span></font><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:10pt;background:yellow;color:blue;font-family:Consolas;">using</span><span style="font-size:10pt;background:yellow;font-family:Consolas;"> System.Web.UI.Design;</span><span style="font-size:10pt;font-family:Consolas;"></span></font><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"> </font></span><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:10pt;color:blue;font-family:Consolas;">namespace</span><span style="font-size:10pt;font-family:Consolas;"> IEWebObjects</span></font><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif">{</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"> </font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>    </span>[<span style="color:#2b91af;">ToolboxData</span>(<span style="color:#a31515;">"&lt;{0}:ShowVisio runat=server&gt;&lt;/{0}:ShowVisio&gt;"</span>)]</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>    </span><span style="color:blue;">public</span> <span style="color:blue;">class</span> <span style="color:#2b91af;">ShowVisio</span> : <span style="color:#2b91af;">WebControl</span></font></span><span style="font-size:10pt;line-height:115%;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>    </span>{</font></span><span><font face="Verdana, Arial, Helvetica, sans-serif"></font></span><span><font face="Verdana, Arial, Helvetica, sans-serif">We are now ready to add the code necessary to make this control functional.<span> </span>First off, we need to create a single private member variable; this variable will be used to contain the path to the Visio diagram file that the user wants to pass to the control.<span> </span>To accomplish this step, create a &#8220;Declarations&#8221; region and key in the following variable declaration:</font></span><span style="font-size:10pt;font-family:'Courier New';"><font face="Verdana, Arial, Helvetica, sans-serif"></font></span><span style="font-size:9pt;font-family:'Courier New';"><font face="Verdana, Arial, Helvetica, sans-serif"><font size="2">#<span style="color:blue;">Region</span> <span style="color:maroon;">&#8220;Declarations&#8221;</span></font></font></span><span style="font-size:9pt;color:maroon;font-family:'Courier New';"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></span><span style="font-size:9pt;font-family:'Courier New';"><font face="Verdana, Arial, Helvetica, sans-serif"><font size="2"><span>    </span><span style="color:blue;">Private</span> mFilePath <span style="color:blue;">As</span> <span style="color:blue;">String</span></font></font></span><span style="font-size:9pt;color:blue;font-family:'Courier New';"><font size="2" face="Verdana, Arial, Helvetica, sans-serif"> </font></span><span style="font-size:9pt;line-height:115%;font-family:'Courier New';"><font face="Verdana, Arial, Helvetica, sans-serif"><font size="2">#<span style="color:blue;">End</span> <span style="color:blue;">Region</span></font></font></span></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Verdana, Arial, Helvetica, sans-serif">Once the variable is declared, we<span>  </span>will need to provide a public property to expose the control property to the control user; in order to accomplish this step, create a &#8220;Properties&#8221; region and key in the following code:</font></p>
<p><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:10pt;color:blue;font-family:Consolas;">#region</span><span style="font-size:10pt;font-family:Consolas;"> &#8220;Properties&#8221;</span></font><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"> </font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>    </span>[<span style="color:#2b91af;">Category</span>(<span style="color:#a31515;">"Source File"</span>)]</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span> </span><span>   </span>[<span style="color:#2b91af;">Browsable</span>(<span style="color:blue;">true</span>)]</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>    </span>[<span style="color:#2b91af;">Description</span>(<span style="color:#a31515;">"Set path to source file."</span>)]</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>    </span>[<span style="color:#2b91af;">Editor</span>(<span style="color:blue;">typeof</span>(System.Web.UI.Design.<span style="color:#2b91af;">UrlEditor</span>), </font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>    </span><span style="color:blue;">typeof</span>(System.Drawing.Design.<span style="color:#2b91af;">UITypeEditor</span>))]</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>    </span><span style="color:blue;">public</span> <span style="color:blue;">string</span> FilePath</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>    </span>{</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>        </span><span style="color:blue;">get</span></font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>        </span>{</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span><span style="color:blue;">return</span> mFilePath;</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>        </span>}</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>        </span><span style="color:blue;">set</span></font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>        </span>{</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span><span style="color:blue;">if</span>(<span style="color:blue;">value</span> == <span style="color:blue;">string</span>.Empty)</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>{</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>                </span>mFilePath = <span style="color:blue;">string</span>.Empty;</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>}</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span><span style="color:blue;">else</span></font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>{</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>               </span><span> </span><span style="color:blue;">int</span> tilde = -1;</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>                </span>tilde = <span style="color:blue;">value</span>.IndexOf(<span style="color:#a31515;">&#8216;~&#8217;</span>);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>                </span><span style="color:blue;">if</span>(tilde != -1)</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>                </span>{</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>                    </span>mFilePath = <span style="color:blue;">value</span>.Substring((tilde + 2)).Trim();</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>                </span>}</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>                </span><span style="color:blue;">else</span></font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>         </span><span>       </span>{</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>                    </span>mFilePath = <span style="color:blue;">value</span>;</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>                </span>}</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>}</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>        </span>}</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>    </span>}<span>   </span><span style="color:green;">// end FilePath property</span></font></span><span style="font-size:10pt;color:green;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"> </font></span></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:10pt;color:blue;line-height:115%;font-family:Consolas;">#endregion</span> </font></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Verdana, Arial, Helvetica, sans-serif">Note that, in the attributes section, the code specifies an editor and further that the editor specified is defined as the URL Editor.<span> </span>Adding this attribute to the control specifies to the IDE how the property is to be edited; in this instance, when the control user sets the File Path property for the control, the property grid will display a button with an ellipsis in it at the right hand side of the text box.<span> </span>If the user clicks on the button, the IDE will open the URL editor and will permit the user to use that editor to navigate to the SWF file and set the File Path property through that editor&#8217;s dialog.<span> </span>Properties set in this manner will be persisted within the control user&#8217;s project.<span>  </span></font></p>
<p><font face="Verdana, Arial, Helvetica, sans-serif">Notice also that the set side of the property strips the tilde character from the beginning of any file path sent to the property; if the value does not contain a tilde, the property is set to contain the path as it is sent.<span> </span>The control will not work if the tilde is left in place as it will not be able to locate the file.</font></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Verdana, Arial, Helvetica, sans-serif">At this point, the only thing left to do is to define how the control will be rendered.<span> </span>To complete this step, create a &#8220;Rendering&#8221; region and within this region, override the RenderContents sub with the following code:</font></p>
<p><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:10pt;color:blue;font-family:Consolas;">#region</span><span style="font-size:10pt;font-family:Consolas;"> &#8220;Rendering&#8221;</span></font><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"> </font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>    </span><span style="color:blue;">protected</span> <span style="color:blue;">override</span> <span style="color:blue;">void</span> RenderContents(<span style="color:#2b91af;">HtmlTextWriter</span> writer)</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>    </span>{</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>        </span><span style="color:blue;">try</span></font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>        </span>{</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span><span style="color:#2b91af;">StringBuilder</span> sb = <span style="color:blue;">new</span> <span style="color:#2b91af;">StringBuilder</span>();</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>sb.Append(<span style="color:#a31515;">&#8220;&lt;object classid=clsid:279D6C9A-652E-4833-BEFC-312CA8887857 </span></font></span><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:10pt;color:#a31515;font-family:Consolas;"><span> </span>id=vviewer &#8220;</span><span style="font-size:10pt;font-family:Consolas;">);</span></font><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>sb.Append(<span style="color:#a31515;">&#8220;codebase=http://download.microsoft.com/download/<span>  </span></span></font></span><font face="Verdana, Arial, Helvetica, sans-serif"><span style="font-size:10pt;color:#a31515;font-family:Consolas;"><span>            </span>4/5/2/452f8090-413f-408f-83c0-edd66db786ee/vviewer.exe Width = &#8220;</span><span style="font-size:10pt;font-family:Consolas;"> + </span></font><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>Width.Value.ToString() + <span style="color:#a31515;">&#8221; Height = &#8220;</span> + Height.Value.ToString() + </font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span> </span><span style="color:#a31515;">&#8221; &gt; &#8220;</span>);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>sb.Append(<span style="color:#a31515;">&#8220;&lt;param name=SRC value=&#8221;</span> + FilePath.ToString() + <span style="color:#a31515;">&#8220;&gt; &#8220;</span>);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>sb.Append(<span style="color:#a31515;">&#8220;&lt;param name=HighQualityRender value=1&gt; &#8220;</span>);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>sb.Append(<span style="color:#a31515;">&#8220;&lt;param name=BackColor value=#000000&gt; &#8220;</span>);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>sb.Append(<span style="color:#a31515;">&#8220;&lt;param name=PageColor value=#000000&gt; &#8220;</span>);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>sb.Append(<span style="color:#a31515;">&#8220;&lt;param name=PageVisible value=1&gt; &#8220;</span>);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>sb.Append(<span style="color:#a31515;">&#8220;&lt;param name=AlertsEnabled value=1&gt; &#8220;</span>);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>sb.Append(<span style="color:#a31515;">&#8220;&lt;param name=ContextMenuEnabled value=1&gt; &#8220;</span>);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>sb.Append(<span style="color:#a31515;">&#8220;&lt;param name=GridVisible value=1&gt; &#8220;</span>);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>sb.Append(<span style="color:#a31515;">&#8220;&lt;param name=PropertyDialogEnabled value=1&gt; &#8220;</span>);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>sb.Append(<span style="color:#a31515;">&#8220;&lt;param name=ScrollbarsVisible value=1&gt; &#8220;</span>);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>sb.Append(<span style="color:#a31515;">&#8220;&lt;param name=ToolbarVisible value=1&gt; &#8220;</span>);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>sb.Append(<span style="color:#a31515;">&#8220;&lt;param name=CurrentPageIndex value=1&gt; &#8220;</span>);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>sb.Append(<span style="color:#a31515;">&#8220;&lt;param name=Zoom value=-1&gt; &#8220;</span>);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>sb.Append(<span style="color:#a31515;">&#8220;&lt;/object&gt;&#8221;</span>);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"></font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>writer.RenderBeginTag(<span style="color:#2b91af;">HtmlTextWriterTag</span>.Div);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>writer.Write(sb.ToString());</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>writer.RenderEndTag();</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>        </span>}</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>        </span><span style="color:blue;">catch</span></font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>        </span>{</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span><span style="color:green;">// with no properties set, this will render &#8220;Display Visio Control&#8221;<span>                   </span></span></font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span><span style="color:green;">// in a box on the page</span></font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>writer.RenderBeginTag(<span style="color:#2b91af;">HtmlTextWriterTag</span>.Div);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>writer.Write(<span style="color:#a31515;">&#8220;Display Visio Control&#8221;</span>);</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>            </span>writer.RenderEndTag();</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>        </span>}<span>  </span><span style="color:green;">// end try-catch</span></font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span>    </span>}<span>   </span><span style="color:green;">// end RenderContents</span></font></span><span style="font-size:10pt;color:green;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"> </font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif"><span></span></font></span></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><span style="font-size:10pt;color:blue;line-height:115%;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif">#endregion</font></span></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Verdana, Arial, Helvetica, sans-serif">Within this code there are a few things worth looking at; first, you can see how the embedded object tag is created<span>  </span>and it does not take too much imagination to figure out that you can embed any valid object using this same approach.<span> </span>The string builder collects three variables from the control, the File Path is passed to the object&#8217;s source<span>  </span>and the controls height and width are also collected and passed to the object tag.<span> </span>The rest of the parameters are canned in this demonstration but could be replaced with additional properties which could also be set at design time if so desired.</font></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Verdana, Arial, Helvetica, sans-serif">The height and width of the control are set using the height and width properties of the web control; no additional properties were added in order to support setting the height and width.<span> </span>In use, the developer using the control could set the control&#8217;s height and width property to any fixed or percentage value and when rendered, the control will expand to fill the available size.</font></p>
<p><font face="Verdana, Arial, Helvetica, sans-serif">Having defined the contents of the object tag, the only detail remaining is to put the control on the rendered page.<span> </span>This is accomplished in the three lines following the definition of the string builder:</p>
<p></font><span style="font-size:9pt;font-family:'Courier New';"><font face="Verdana, Arial, Helvetica, sans-serif"><font size="2">writer.RenderBeginTag(<span style="color:#2b91af;">HtmlTextWriterTag</span>.Div);<br />
<span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif">writer.Write(sb.ToString());<br />
</font></span><span style="font-size:10pt;font-family:Consolas;"><font face="Verdana, Arial, Helvetica, sans-serif">writer.RenderEndTag();</font></span></font></font></span><span style="font-size:9pt;font-family:'Courier New';"><font face="Verdana, Arial, Helvetica, sans-serif"><font size="2"></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font size="2" face="Verdana, Arial, Helvetica, sans-serif">In this example, the HTML writer is set up to place an opening Div tag, within the Div, the object defined in the string builder is written to the rendered page, and in the last line, the Div is closed.</font></p>
<p></font></font></span></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Verdana, Arial, Helvetica, sans-serif">The control is now complete.<span> </span>Prior to testing the control, rebuild the project.<span> </span>Once that has been completed and any errors encountered are repaired, it is time to test the control.<span> </span>To test the control, add a new web site project to the web control library project currently open.<span> </span>Once the test web site has been created, set the test project as the start up project by right clicking on the web site solution in the solution explorer and selecting the &#8220;Set as Start Up Project&#8221; menu option.<span> </span>Next, locate the Default.aspx page in the web site solution, right click on this page and select the &#8220;Set as Start Page&#8221; menu option.</font></p>
<p><font face="Verdana, Arial, Helvetica, sans-serif">Open the Default.aspx page for editing.<span> </span>Locate the newly created control in the toolbox (it should be at the top) and drag the &#8220;<em>ShowVisio</em>&#8221; control onto the page (Figure 3).</p>
<p></font><font face="Verdana, Arial, Helvetica, sans-serif"><strong><br />
<font face="Verdana, Arial, Helvetica, sans-serif"><strong><img border="0" align="baseline" src="http://www.c-sharpcorner.com/UploadFile/scottlysle/CC_Visio01142007140634PM/Images/Showvision3.gif" /></strong></font></p>
<p></strong>Figure 3:<span> </span>Custom Control in Toolbox</font><font face="Verdana, Arial, Helvetica, sans-serif"> </font></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Verdana, Arial, Helvetica, sans-serif">You may now click on the &#8220;<em>ShowVisio</em>&#8221; control and set its height, width, and file path properties.<span> </span>If you are working with the demo project included with the download, there is a Visio folder with two Visio diagrams included in that folder.<span> </span>You can set the file path property to point to one of these files.</font></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Verdana, Arial, Helvetica, sans-serif">The demo project also includes a hyperlink, you can point the NavigateUrl property to the other Visio diagram.<span> </span>Internet Explorer will open Visio diagrams into a new web page but the web page will contain only the Visio diagram.<span> </span>If you just want to display a plain diagram without controlling the appearance of the web page containing the diagram, then this an easier way to get there.<span> </span>If you want to display the diagram in a formatted page, then the use of the custom control is a better way to go about it.</font></p>
<p><font face="Verdana, Arial, Helvetica, sans-serif">Build the application and run it; you should now be looking at a Visio diagram displayed within the custom control (Figure 4).<br />
</font><font face="Verdana, Arial, Helvetica, sans-serif"><br />
<strong><br />
<strong><img border="0" align="baseline" src="http://www.c-sharpcorner.com/UploadFile/scottlysle/CC_Visio01142007140634PM/Images/Showvision4.gif" /></strong></p>
<p></strong>Figure 4:<span> </span>Visio Displayed in the Custom Control</font><b><font face="Verdana, Arial, Helvetica, sans-serif"> </font></b><b><font face="Verdana, Arial, Helvetica, sans-serif">Summary</font></b></p>
<p style="margin:0 0 10pt;" class="MsoNormal"><font face="Verdana, Arial, Helvetica, sans-serif">This example project demonstrated an approach to displaying a Visio diagram within a custom control embedded into a web page.<span> </span>It is possible to navigate directly to a Visio diagram from Internet Explorer and Internet Explorer will attempt to render the diagram in the Visio viewer control if possible.<span> </span>This functionality is not supported in non-Microsoft browsers however, when browsers such as FireFox encounter the diagram, they prompt the user to download the file where it may be viewed locally but any user with Visio installed (in Internet Explorer).</font></p>
<p><font face="Verdana, Arial, Helvetica, sans-serif">While Internet Explorer can navigate to and display a Visio file; packaging the Visio Viewer control up as a custom control allows the developer using the control the option of embedding the control into a formatted and populated web page.</font></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gvsradhika.wordpress.com/5/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gvsradhika.wordpress.com/5/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gvsradhika.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gvsradhika.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gvsradhika.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gvsradhika.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gvsradhika.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gvsradhika.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gvsradhika.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gvsradhika.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gvsradhika.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gvsradhika.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gvsradhika.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gvsradhika.wordpress.com/5/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gvsradhika.wordpress.com/5/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gvsradhika.wordpress.com/5/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gvsradhika.wordpress.com&amp;blog=3053177&amp;post=5&amp;subd=gvsradhika&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gvsradhika.wordpress.com/2008/03/07/creating-aspnet-20-visio-custom-control/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/951b10b49131c5b496c961e87d283d6e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gvsradhika</media:title>
		</media:content>

		<media:content url="http://www.c-sharpcorner.com/UploadFile/scottlysle/CC_Visio01142007140634PM/Images/Showvision1.gif" medium="image" />

		<media:content url="http://www.c-sharpcorner.com/UploadFile/scottlysle/CC_Visio01142007140634PM/Images/Showvision2.gif" medium="image" />

		<media:content url="http://www.c-sharpcorner.com/UploadFile/scottlysle/CC_Visio01142007140634PM/Images/Showvision3.gif" medium="image" />

		<media:content url="http://www.c-sharpcorner.com/UploadFile/scottlysle/CC_Visio01142007140634PM/Images/Showvision4.gif" medium="image" />
	</item>
		<item>
		<title>SEND AN EMAIL USING SMTP SERVICE IN ASP.NET 2.0 &amp; C#.NET</title>
		<link>http://gvsradhika.wordpress.com/2008/03/04/send-an-email-using-smtp-service-in-aspnet-20-cnet/</link>
		<comments>http://gvsradhika.wordpress.com/2008/03/04/send-an-email-using-smtp-service-in-aspnet-20-cnet/#comments</comments>
		<pubDate>Tue, 04 Mar 2008 05:00:26 +0000</pubDate>
		<dc:creator>gvsradhika</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://gvsradhika.wordpress.com/?p=4</guid>
		<description><![CDATA[Before Coding you should add few assembles in the default.aspx.cs file as below: using System.Web; using System.Net.Mail; Thats all..and then.. 1)How do you send a simple plain text email ? //create the mail message MailMessage mail = new MailMessage();//set the addresses mail.From = new MailAddress("me@mycompany.com"); mail.To.Add("you@yourcompany.com");//set the content mail.Subject = "This is an email"; mail.Body [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gvsradhika.wordpress.com&amp;blog=3053177&amp;post=4&amp;subd=gvsradhika&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p><code><strong>Before Coding you should add few assembles in the default.aspx.cs file as below:</strong></code></p>
<p><code><strong>using System.Web;</strong></code></p>
<p><code><strong>using System.Net.Mail;</strong></code></p>
<p><code><strong>Thats all..and then..</strong></code></p>
<p><code><strong>1)How do you send a simple plain text email ?</strong></code></p>
<p><code>//create the mail message<br />
MailMessage mail = new MailMessage();</code><code>//set the addresses<br />
mail.From = new MailAddress("me@mycompany.com");<br />
mail.To.Add("you@yourcompany.com");</code><code>//set the content<br />
mail.Subject = "This is an email";<br />
mail.Body = "this is a sample body";</code><code>//send the message<br />
SmtpClient smtp = new SmtpClient("127.0.0.1");<br />
smtp.Send(mail);</code><code>The above code is provided in C# and should be written in the back end file (default.aspx.cs)</p>
<p><strong>2)How do you send a simple Html email?</strong></p>
<p></code><br />
<code>//create the mail message<br />
 MailMessage mail = new MailMessage();</code><code>//set the addresses<br />
 mail.From = new MailAddress("me@mycompany.com");<br />
 mail.To.Add("you@yourcompany.com");</code><code>//set the content<br />
 mail.Subject = "This is an email";<br />
 mail.Body = "this is a sample body with html in it. <b>This is bold</b> <font color="#336699">This is blue</font>";<br />
 mail.IsBodyHtml = true;</code><code>//send the message<br />
 SmtpClient smtp = new SmtpClient("127.0.0.1");<br />
 smtp.Send(mail);<br />
The above code should also be in (default.aspx.cs) file.</p>
<p><strong>3)How do I send an email with attachments?</strong></p>
<p></code><br />
<code>static void AttachmentFromFile()<br />
{<br />
//create the mail message<br />
MailMessage mail = new MailMessage();</code><code>//set the addresses<br />
mail.From = new MailAddress("me@mycompany.com");<br />
mail.To.Add("you@yourcompany.com");</code><code>//set the content<br />
mail.Subject = "This is an email";<br />
mail.Body = "this content is in the body";</p>
<p>//add an attachment from the filesystem<br />
mail.Attachments.Add(new Attachment("c:\\temp\\example.txt"));</p>
<p>//to add additional attachments, simply call .Add(...) again<br />
mail.Attachments.Add(new Attachment("c:\\temp\\example2.txt"));<br />
mail.Attachments.Add(new Attachment("c:\\temp\\example3.txt"));</p>
<p>//send the message<br />
SmtpClient smtp = new SmtpClient("127.0.0.1");<br />
smtp.Send(mail);</p>
<p>}</p>
<p>That's it. Your mail will be send to the mail id you have mentioned in To field.</p>
<p>Happy Coding.</p>
<p></code></p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/gvsradhika.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/gvsradhika.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/gvsradhika.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/gvsradhika.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/gvsradhika.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/gvsradhika.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/gvsradhika.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/gvsradhika.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/gvsradhika.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/gvsradhika.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/gvsradhika.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/gvsradhika.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/gvsradhika.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/gvsradhika.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/gvsradhika.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/gvsradhika.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=gvsradhika.wordpress.com&amp;blog=3053177&amp;post=4&amp;subd=gvsradhika&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://gvsradhika.wordpress.com/2008/03/04/send-an-email-using-smtp-service-in-aspnet-20-cnet/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/951b10b49131c5b496c961e87d283d6e?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">gvsradhika</media:title>
		</media:content>
	</item>
	</channel>
</rss>
