tag:blogger.com,1999:blog-61843364693926563962024-03-14T09:31:45.704-07:00Code ShodeTalhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comBlogger62125tag:blogger.com,1999:blog-6184336469392656396.post-30592220627196844052014-02-11T08:58:00.000-08:002014-02-11T08:58:05.803-08:00MS SQL Server Function to Insert Line Break in String<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
Today I came across a situation where I had to break a string coming from SQL and show it in different lines on HTML. I know it's a weird situation, but so is programming :)<br />
<br />
I googled for it but couldn't find an exact solution so I decided to write an SQL user-defined function myself.<br />
While writing a function a thought why only limit it to a line-break (<br/>) So i made it more generic.<br />
<br />
here is the function:<br />
<span style="color: blue; font-family: 'Courier New'; font-size: x-small;">CREATE</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">FUNCTION</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">[dbo]</span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">.</span><span style="color: #ff0080; font-family: 'Courier New'; font-size: x-small;"><b>Stringlinebreak</b></span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">(</span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@String</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="font-family: 'Courier New'; font-size: x-small;"><i>NVARCHAR</i></span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">(</span><span style="font-family: 'Courier New'; font-size: x-small;">1000</span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">)</span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">,</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@Length</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="font-family: 'Courier New'; font-size: x-small;"><i>INT</i></span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">,</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@Char</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="font-family: 'Courier New'; font-size: x-small;"><i>VARCHAR</i></span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">(</span><span style="font-family: 'Courier New'; font-size: x-small;">5</span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">)</span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">)</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">returns</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="font-family: 'Courier New'; font-size: x-small;"><i>NVARCHAR</i></span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">(</span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">max</span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">)</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">BEGIN</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">DECLARE</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@ReturnString</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="font-family: 'Courier New'; font-size: x-small;"><i>NVARCHAR</i></span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">(</span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">max</span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">)</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">DECLARE</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@ActualLength</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="font-family: 'Courier New'; font-size: x-small;"><i>INT</i></span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">DECLARE</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@I</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="font-family: 'Courier New'; font-size: x-small;"><i>INT</i></span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">SET</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@ReturnString</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">=</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@String</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">SELECT</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@ActualLength</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">=</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: magenta; font-family: 'Courier New'; font-size: x-small;"><i>Len</i></span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">(</span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@String</span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">)</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">IF</span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">(</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@ActualLength</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">></span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">(</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@Length</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">*</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="font-family: 'Courier New'; font-size: x-small;">2</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">)</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">)</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">BEGIN</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">SET</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@I</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">=</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@Length</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">WHILE</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@I</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;"><=</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@ActualLength</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">BEGIN</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">SELECT</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@ReturnString</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">=</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: magenta; font-family: 'Courier New'; font-size: x-small;"><i>Stuff</i></span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">(</span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@ReturnString</span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">,</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@I</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">-</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="font-family: 'Courier New'; font-size: x-small;">5</span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">,</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="font-family: 'Courier New'; font-size: x-small;">1</span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">,</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: magenta; font-family: 'Courier New'; font-size: x-small;"><i>Substring</i></span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">(</span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@ReturnString</span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">,</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@I</span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">-</span><span style="font-family: 'Courier New'; font-size: x-small;">5</span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">,</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="font-family: 'Courier New'; font-size: x-small;">1</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">)</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">+</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@Char</span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">)</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">SET</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@I</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">=</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@I</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">+</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@Length</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">END</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">END</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">ELSE</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">BEGIN</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">SELECT</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@ReturnString</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">=</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">CASE</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">WHEN</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@ActualLength</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">></span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@Length</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">THEN</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: magenta; font-family: 'Courier New'; font-size: x-small;"><i>Stuff</i></span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">(</span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@String</span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">,</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@Length</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">-</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="font-family: 'Courier New'; font-size: x-small;">5</span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">,</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="font-family: 'Courier New'; font-size: x-small;">1</span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">,</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: magenta; font-family: 'Courier New'; font-size: x-small;"><i>Substring</i></span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">(</span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@String</span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">,</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@Length</span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">-</span><span style="font-family: 'Courier New'; font-size: x-small;">5</span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">,</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="font-family: 'Courier New'; font-size: x-small;">1</span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">)</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">+</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@Char</span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">)</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">ELSE</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@String</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">END</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">END</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">RETURN</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: #8000ff; font-family: 'Courier New'; font-size: x-small;">@ReturnString</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br style="font-family: 'Courier New'; font-size: small;" /><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: blue; font-family: 'Courier New'; font-size: x-small;">END</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br />
<span style="font-family: 'Courier New'; font-size: x-small;"><br /></span>
<br />
it can be used as:<br />
<br />
<span style="color: blue; font-family: 'Courier New'; font-size: x-small;">SELECT</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">[dbo]</span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">.</span><span style="color: #ff0080; font-family: 'Courier New'; font-size: x-small;"><b>Stringlinebreak</b></span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">(</span><span style="color: red; font-family: 'Courier New'; font-size: x-small;">'Microsoft Certified Database Administrator on Microsoft SQL Server 2000'</span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">,</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="font-family: 'Courier New'; font-size: x-small;">30</span><span style="color: silver; font-family: 'Courier New'; font-size: x-small;">,</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><span style="color: red; font-family: 'Courier New'; font-size: x-small;">'<br/>'</span><span style="color: maroon; font-family: 'Courier New'; font-size: x-small;">)</span><span style="font-family: 'Courier New'; font-size: x-small;"> </span><br />
<br />
<br />
and the output will be:<br />
<span style="background-color: white; color: #333333; font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; font-size: 13px; line-height: 18px;">Microsoft Certified Datab<br/>ase Administrator on Micr<br/>osoft SQL Server 2000</span><br />
<br />
<br />
So when it is displayed in HTML, the string is with line breaks.<br />
<br />
You can try this code, here at <a href="http://sqlfiddle.com/#!3/ba06c/1/0" target="_blank"><i>SQL Fiddle</i></a><br />
<br />
I hope it helps someone else too.<br />
<br />
Happy Coding!<br />
<br /></div>
Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-28451216486142174602012-09-19T06:42:00.000-07:002012-09-19T06:48:17.738-07:00Fix HTML Table Header While Scrolling Page Using jQuery<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div class="MsoNormal">
I have heard this question various times:</div>
<blockquote class="tr_bq">
<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Arial Black', sans-serif; font-size: 26pt;">“</span>Is there a cross-browser CSS/JavaScript technique to
display a long HTML table such that the column headers stay fixed on-screen and
do not scroll with the table body like the "freeze panes" effect in Microsoft
Excel<span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: Arial, sans-serif; font-size: 10pt;">.</span><span style="background-color: white; background-position: initial initial; background-repeat: initial initial; font-family: 'Arial Black', sans-serif; font-size: 26pt;">”</span></blockquote>
<div class="MsoNormal">
This blog post display how can we use a little bit of jQuery
tweaking to fix position for the header of asp:Repeater (or any table header). It will keep the header
to float and be always on top.</div>
<div class="MsoNormal">
Lets have a quick example for<b> How to Fix HTML Table Header while scrolling page</b>.</div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><u>ASPX:</u></b></div>
<div class="MsoNormal">
<b><u><br /></u></b></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">table</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">id</span><span style="color: blue;">="tblEmployee"</span> <span style="color: red;">border</span><span style="color: blue;">="0"</span> <span style="color: red;">cellpadding</span><span style="color: blue;">="5"</span> <span style="color: red;">cellspacing</span><span style="color: blue;">="1"</span> <span style="color: red;">class</span><span style="color: blue;">="tblborder"</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">width</span><span style="color: blue;">="100%"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">thead</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">tr</span> <span style="color: red;">class</span><span style="color: blue;">="header"</span>
<span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">font-weight</span><span style="color: blue;">: bold;"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"><</span><span style="color: maroon;">td</span>
<span style="color: red;">align</span><span style="color: blue;">="center"</span><span style="color: maroon;"> </span><span style="color: red;">colspan</span><span style="color: blue;">="7” ></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
Employee List<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">tr</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">tr</span> <span style="color: red;">class</span><span style="color: blue;">="header"</span>
<span style="color: red;">style</span><span style="color: blue;">="</span><span style="color: red;">font-weight</span><span style="color: blue;">: bold;"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"><</span><span style="color: maroon;">td</span>
<span style="color: red;">align</span><span style="color: blue;">="center"</span>
<span style="color: red;">width</span><span style="color: blue;">="3%"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
S.No.<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"><</span><span style="color: maroon;">td</span>
<span style="color: red;">align</span><span style="color: blue;">="center"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
Employee Code<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"><</span><span style="color: maroon;">td</span>
<span style="color: red;">align</span><span style="color: blue;">="center"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
Employee Name<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"><</span><span style="color: maroon;">td</span>
<span style="color: red;">align</span><span style="color: blue;">="center"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
Department<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"><</span><span style="color: maroon;">td</span>
<span style="color: red;">align</span><span style="color: blue;">="center"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
Designation<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"><</span><span style="color: maroon;">td</span>
<span style="color: red;">align</span><span style="color: blue;">="center"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
Manager<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"><</span><span style="color: maroon;">td</span>
<span style="color: red;">align</span><span style="color: blue;">="center"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
Action<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">tr</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">thead</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">tbody</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Repeater</span> <span style="color: red;">ID</span><span style="color: blue;">="rptEmployee"</span>
<span style="color: red;">runat</span><span style="color: blue;">="server"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"><</span><span style="color: maroon;">ItemTemplate</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"><</span><span style="color: maroon;">tr</span>
<span style="color: red;">class</span><span style="color: blue;">="bgGray
repeaterRow"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"</span> <span style="color: red;">valign</span><span style="color: blue;">="top"</span> <span style="color: red;">width</span><span style="color: blue;">="3%"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;"><%</span><span style="color: blue;">#</span> Container.ItemIndex + 1 <span style="background: yellow; mso-highlight: yellow;">%></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"</span> <span style="color: red;">valign</span><span style="color: blue;">="top"</span> <span style="color: red;">nowrap</span><span style="color: blue;">="nowrap"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">HiddenField</span> <span style="color: red;">ID</span><span style="color: blue;">="hdEmployee_ID"</span>
<span style="color: red;">runat</span><span style="color: blue;">="server"</span>
<span style="color: red;">Value</span><span style="color: blue;">='</span><span style="background: yellow; mso-highlight: yellow;"><%</span><span style="color: blue;">#</span>Eval("Employee_ID")<span style="background: yellow; mso-highlight: yellow;">%></span><span style="color: blue;">'</span> <span style="color: blue;">/></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;"><%</span><span style="color: blue;">#</span>Eval(<span style="color: #a31515;">"Employee_Code"</span>)<span style="background: yellow; mso-highlight: yellow;">%></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"</span> <span style="color: red;">valign</span><span style="color: blue;">="top"</span> <span style="color: red;">nowrap</span><span style="color: blue;">="nowrap"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;"><%</span><span style="color: blue;">#</span>Eval(<span style="color: #a31515;">"Employee_Name"</span>)<span style="background: yellow; mso-highlight: yellow;">%></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"</span> <span style="color: red;">width</span><span style="color: blue;">="10%"</span> <span style="color: red;">nowrap</span><span style="color: blue;">="nowrap"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;"><%</span><span style="color: blue;">#</span>Eval(<span style="color: #a31515;">"Department_Name"</span>)<span style="background: yellow; mso-highlight: yellow;">%></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"</span> <span style="color: red;">valign</span><span style="color: blue;">="top"</span> <span style="color: red;">width</span><span style="color: blue;">="10%"</span> <span style="color: red;">nowrap</span><span style="color: blue;">="nowrap"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;"><%</span><span style="color: blue;">#</span>Eval(<span style="color: #a31515;">"Designation_Name"</span>)<span style="background: yellow; mso-highlight: yellow;">%></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"</span> <span style="color: red;">valign</span><span style="color: blue;">="top"</span> <span style="color: red;">width</span><span style="color: blue;">="20%"</span> <span style="color: red;">nowrap</span><span style="color: blue;">="nowrap"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;"><%</span><span style="color: blue;">#</span>Eval(<span style="color: #a31515;">"Manager_Name"</span>)<span style="background: yellow; mso-highlight: yellow;">%></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"</span> <span style="color: red;">valign</span><span style="color: blue;">="top"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">a</span> <span style="color: red;">id</span><span style="color: blue;">="aEdit"</span>
<span style="color: red;">runat</span><span style="color: blue;">="server"</span>
<span style="color: red;">href</span><span style="color: blue;">='</span><span style="background: yellow; mso-highlight: yellow;"><%</span><span style="color: blue;">#</span>
Eval("Employee_ID","EditEmployee.aspx?Employee_ID={0}" ) <span style="background: yellow; mso-highlight: yellow;">%></span><span style="color: blue;">'></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> Edit<span style="color: blue;"></</span><span style="color: maroon;">a</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"></</span><span style="color: maroon;">tr</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"></</span><span style="color: maroon;">ItemTemplate</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"><</span><span style="color: maroon;">AlternatingItemTemplate</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"><</span><span style="color: maroon;">tr</span>
<span style="color: red;">class</span><span style="color: blue;">="bgAlt
repeaterRow"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"</span> <span style="color: red;">valign</span><span style="color: blue;">="top"</span> <span style="color: red;">width</span><span style="color: blue;">="3%"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;"><%</span><span style="color: blue;">#</span> Container.ItemIndex + 1 <span style="background: yellow; mso-highlight: yellow;">%></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"</span> <span style="color: red;">valign</span><span style="color: blue;">="top"</span> <span style="color: red;">nowrap</span><span style="color: blue;">="nowrap"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">HiddenField</span> <span style="color: red;">ID</span><span style="color: blue;">="hdEmployee_ID"</span>
<span style="color: red;">runat</span><span style="color: blue;">="server"</span>
<span style="color: red;">Value</span><span style="color: blue;">='</span><span style="background: yellow; mso-highlight: yellow;"><%</span><span style="color: blue;">#</span>Eval("Employee_ID")<span style="background: yellow; mso-highlight: yellow;">%></span><span style="color: blue;">'</span> <span style="color: blue;">/></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;"><%</span><span style="color: blue;">#</span>Eval(<span style="color: #a31515;">"Employee_Code"</span>)<span style="background: yellow; mso-highlight: yellow;">%></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"</span> <span style="color: red;">valign</span><span style="color: blue;">="top"</span> <span style="color: red;">nowrap</span><span style="color: blue;">="nowrap"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;"><%</span><span style="color: blue;">#</span>Eval(<span style="color: #a31515;">"Employee_Name"</span>)<span style="background: yellow; mso-highlight: yellow;">%></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"</span> <span style="color: red;">width</span><span style="color: blue;">="10%"</span> <span style="color: red;">nowrap</span><span style="color: blue;">="nowrap"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;"><%</span><span style="color: blue;">#</span>Eval(<span style="color: #a31515;">"Department_Name"</span>)<span style="background: yellow; mso-highlight: yellow;">%></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"</span> <span style="color: red;">valign</span><span style="color: blue;">="top"</span> <span style="color: red;">width</span><span style="color: blue;">="10%"</span> <span style="color: red;">nowrap</span><span style="color: blue;">="nowrap"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;"><%</span><span style="color: blue;">#</span>Eval(<span style="color: #a31515;">"Designation_Name"</span>)<span style="background: yellow; mso-highlight: yellow;">%></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"</span> <span style="color: red;">valign</span><span style="color: blue;">="top"</span> <span style="color: red;">width</span><span style="color: blue;">="20%"</span> <span style="color: red;">nowrap</span><span style="color: blue;">="nowrap"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="background: yellow; mso-highlight: yellow;"><%</span><span style="color: blue;">#</span>Eval(<span style="color: #a31515;">"Manager_Name"</span>)<span style="background: yellow; mso-highlight: yellow;">%></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">td</span> <span style="color: red;">align</span><span style="color: blue;">="center"</span> <span style="color: red;">valign</span><span style="color: blue;">="top"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">a</span> <span style="color: red;">id</span><span style="color: blue;">="aEdit"</span>
<span style="color: red;">runat</span><span style="color: blue;">="server"</span>
<span style="color: red;">href</span><span style="color: blue;">='</span><span style="background: yellow; mso-highlight: yellow;"><%</span><span style="color: blue;">#</span>
Eval("Employee_ID","EditEmployee.aspx?Employee_ID={0}" ) <span style="background: yellow; mso-highlight: yellow;">%></span><span style="color: blue;">'></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> Edit<span style="color: blue;"></</span><span style="color: maroon;">a</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">td</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"></</span><span style="color: maroon;">tr</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;"></</span><span style="color: maroon;">AlternatingItemTemplate</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Repeater</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">tbody</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">table</span><span style="color: blue;">><o:p></o:p></span></span></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><u>CSS:</u></b></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">.tblborder</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">background-color</span>: <span style="color: blue;">#7c7a90</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">font-family</span>: <span style="color: blue;">Calibri</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">font-size</span>: <span style="color: blue;">12px</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">font-weight</span>: <span style="color: blue;">bold</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">text-align</span>: <span style="color: blue;">center</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">.header</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">border</span>: <span style="color: blue;">1px</span> <span style="color: blue;">solid</span> <span style="color: blue;">#aed0ea</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">color</span>: <span style="color: blue;">Gray</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">font-weight</span>: <span style="color: blue;">bold</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">font-size</span>: <span style="color: blue;">14px</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">font-family</span>: <span style="color: blue;">Tahoma</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">background</span>: <span style="color: blue;">#d7ebf9</span> <span style="color: blue;">url(../../../Styles/images/ui-bg_glass_80_d7ebf9_1x400.png)</span>
<span style="color: blue;">50%</span> <span style="color: blue;">50%</span> <span style="color: blue;">repeat-x</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">text-align</span>:<span style="color: blue;">left</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">} <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">.bgGray</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">font-weight</span>: <span style="color: blue;">normal</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">background</span>: <span style="color: blue;">#f2f5f7</span> <span style="color: blue;">url(../../../Styles/images/ui-bg_diamond_100_f2f5f7_10x8.png)</span>
<span style="color: blue;">50%</span> <span style="color: blue;">50%</span> <span style="color: blue;">repeat</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">color</span>: <span style="color: blue;">#362b36</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">padding</span>:<span style="color: blue;">3px</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">.bgAlt</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">background</span>: <span style="color: blue;">#eff6fc</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">font-weight</span>: <span style="color: blue;">normal</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">color</span>: <span style="color: blue;">#362b36</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">padding</span>:<span style="color: blue;">3px</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">.highlightRow</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">background</span>: <span style="color: blue;">rgb(228,245,252)</span>;
<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">color</span>: <span style="color: blue;">Black</span>;</span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">.repeaterRow</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">text-decoration</span>: <span style="color: blue;">none</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal">
<b><u>jQuery/Javascript:</u></b></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"></span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">jQuery.fn.fixedtableheader = <span style="color: blue;">function</span> (options) {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">var</span> settings = jQuery.extend({<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
headerrowsize: 1,<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
highlightrow: <span style="color: blue;">false</span>,<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
highlightclass: <span style="color: maroon;">"highlight"</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> },
options);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">this</span>.each(<span style="color: blue;">function</span>
(i) {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">var</span> $tbl = $(<span style="color: blue;">this</span>);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">var</span> $tblhfixed = $tbl.find(<span style="color: maroon;">"tr:lt("</span>
+ settings.headerrowsize + <span style="color: maroon;">")"</span>);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">var</span> headerelement = <span style="color: maroon;">"thead"</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> ($tblhfixed.find(headerelement).length == 0)
headerelement = <span style="color: maroon;">"td"</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> ($tblhfixed.find(headerelement).length > 0) {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> $tblhfixed.find(headerelement).each(<span style="color: blue;">function</span> () {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
$(<span style="color: blue;">this</span>).css(<span style="color: maroon;">"width"</span>,
$(<span style="color: blue;">this</span>).width());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
});<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">var</span> $clonedTable = $tbl.clone().empty();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">var</span> tblwidth = GetTblWidth($tbl);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
$clonedTable.attr(<span style="color: maroon;">"id"</span>, <span style="color: maroon;">"fixedtableheader"</span> + i).css({<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: maroon;">"position"</span>: <span style="color: maroon;">"fixed"</span>,<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: maroon;">"top"</span>: <span style="color: maroon;">"0"</span>,<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: maroon;">"left"</span>: $tbl.offset().left<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
}).append($tblhfixed.clone()).width(tblwidth).hide().appendTo($(<span style="color: maroon;">"body"</span>));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (settings.highlightrow) $(<span style="color: maroon;">"tr:gt("</span>
+ (settings.headerrowsize - 1) + <span style="color: maroon;">")"</span>,
$tbl).hover(<span style="color: blue;">function</span> () {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
$(<span style="color: blue;">this</span>).addClass(settings.highlightclass);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
}, <span style="color: blue;">function</span> () {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
$(<span style="color: blue;">this</span>).removeClass(settings.highlightclass);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> });<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
$(window).scroll(<span style="color: blue;">function</span> () {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;">if</span> (jQuery.browser.msie &&
jQuery.browser.version == <span style="color: maroon;">"6.0"</span>)
$clonedTable.css({<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: maroon;">"position"</span>: <span style="color: maroon;">"absolute"</span>,<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: maroon;">"top"</span>:
$(window).scrollTop(),<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: maroon;">"left"</span>: $tbl.offset().left<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
});<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;">else</span> $clonedTable.css({<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: maroon;">"position"</span>: <span style="color: maroon;">"fixed"</span>,<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: maroon;">"top"</span>: <span style="color: maroon;">"0"</span>,<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: maroon;">"left"</span>: $tbl.offset().left -
$(window).scrollLeft()<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> });<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;">var</span> sctop = $(window).scrollTop();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;">var</span> elmtop = $tblhfixed.offset().top;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;">if</span> (sctop > elmtop && sctop
<= (elmtop + $tbl.height() - $tblhfixed.height())) $clonedTable.show();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;">else</span> $clonedTable.hide();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
});<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
$(window).resize(<span style="color: blue;">function</span> () {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
<span style="color: blue;">if</span> ($clonedTable.outerWidth() !=
$tbl.outerWidth()) {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
$tblhfixed.find(headerelement).each(<span style="color: blue;">function</span>
(index) {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">var</span> w = $(<span style="color: blue;">this</span>).width();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> $(<span style="color: blue;">this</span>).css(<span style="color: maroon;">"width"</span>,
w);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
$clonedTable.find(headerelement).eq(index).css(<span style="color: maroon;">"width"</span>,
w);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
});<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
$clonedTable.width($tbl.outerWidth());<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
}<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> $clonedTable.css(<span style="color: maroon;">"left"</span>, $tbl.offset().left);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
});<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> });<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">function</span> GetTblWidth($tbl) {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">var</span> tblwidth = $tbl.outerWidth();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> tblwidth;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">};<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">script</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"></span>
<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> $(<span style="color: blue;">function</span> () {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
$(<span style="color: maroon;">"#tblEmployee"</span>).fixedtableheader({<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
headerrowsize: 2<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
});<o:p></o:p></span><span style="font-family: Consolas; font-size: 9.5pt;"> </span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"><br /></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: darkgreen;">/* to highlight row on mouseover*/<o:p></o:p></span></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
$(<span style="color: maroon;">'.repeaterRow'</span>).hover(<span style="color: blue;">function</span> () {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
$(<span style="color: blue;">this</span>).children().addClass(<span style="color: maroon;">'highlightRow'</span>);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
}, <span style="color: blue;">function</span> () {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
$(<span style="color: blue;">this</span>).children().removeClass(<span style="color: maroon;">'highlightRow'</span>);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
});<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> });<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">script</span><span style="color: blue;">></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
And that’s it. Just
place this <span style="font-family: Consolas; font-size: 9.5pt;">fixedtableheader</span>
function in a general javascript file reuse and call this function wherever you
want. Only thing to remember is to follow the table structure as mentioned. Let
me know if anything is not clear</div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<o:p>Happy Coding!</o:p><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUAfFl5XWPaTO9K8Dp4zDJ_QUI1ODUNARTbPXPTt-XP3g0Ml3iDJUFeKTcvXN69BwuXyD3-GCfKEfBEPesIK62MWcAcD8XtcYQ_fd5BWO2N2NhjALAWZzpPWCULxfTdRhe4-JvPsxqCms/s1600/fix-html-table-header-while-scrolling.PNG" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="129" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjUAfFl5XWPaTO9K8Dp4zDJ_QUI1ODUNARTbPXPTt-XP3g0Ml3iDJUFeKTcvXN69BwuXyD3-GCfKEfBEPesIK62MWcAcD8XtcYQ_fd5BWO2N2NhjALAWZzpPWCULxfTdRhe4-JvPsxqCms/s640/fix-html-table-header-while-scrolling.PNG" width="640" /></a></div>
<o:p><br /></o:p></div>
<div class="MsoNormal">
<br /></div>
</div>
Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-15577673399753451482012-06-13T22:55:00.000-07:002012-06-13T23:46:47.855-07:00Upload and Show Profile Picture Based on Session ID in ASP.NET<div dir="ltr" style="text-align: left;" trbidi="on">
<a href="http://forums.asp.net/t/1813397.aspx/1?How+to+upload+and+show+profile+picture+based+on+session+ID+" target="_blank"><b>This</b></a> was a question asked to in asp.net forums. It asked <b>How to Upload and Show Profile Picture Based on Session ID in ASP.NET</b>. I found it interesting and thought to write a post for it. So here we are with the solution:<br />
<br />
<b>FileUpload.aspx</b><br />
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">form</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">id</span><span style="color: blue;">="form1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">div</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">FileUpload</span> <span style="color: red;">ID</span><span style="color: blue;">="FileUploadControl"</span>
<span style="color: red;">runat</span><span style="color: blue;">="server"</span>
<span style="color: blue;">/></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Button</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span>
<span style="color: red;">ID</span><span style="color: blue;">="UploadButton"</span>
<span style="color: red;">Text</span><span style="color: blue;">="Upload"</span>
<span style="color: red;">OnClick</span><span style="color: blue;">="UploadButton_Click"</span>
<span style="color: blue;">/></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Image</span> <span style="color: red;">ID</span><span style="color: blue;">="ProfilePic"</span>
<span style="color: red;">runat</span><span style="color: blue;">="server"</span>
<span style="color: red;">Height</span><span style="color: blue;">="150px"</span>
<span style="color: red;">Width</span><span style="color: blue;">="150px"</span>
<span style="color: blue;">/></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Label</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span>
<span style="color: red;">ID</span><span style="color: blue;">="StatusLabel"</span>
<span style="color: red;">Text</span><span style="color: blue;">="Upload
status: "</span> <span style="color: blue;">/></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">div</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">form</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">><o:p></o:p></span></div>
<br />
<br />
<br />
<b>FileUpload.aspx.cs</b><br />
<b><br /></b><br />
<br />
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Collections.Generic;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Linq;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web.UI;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web.UI.WebControls;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">public</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">FileUpload</span> :
System.Web.UI.<span style="color: #2b91af;">Page</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">protected</span> <span style="color: blue;">void</span>
Page_Load(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (Session[<span style="color: #a31515;">"UserSessionID"</span>]
== <span style="color: blue;">null</span>)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
Session[<span style="color: #a31515;">"UserSessionID"</span>] =
System.<span style="color: #2b91af;">Guid</span>.NewGuid().ToString();<span style="color: green;">//probably create
this in global.asax in OnSessionStart event</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> ProfilePic.ImageUrl = <span style="color: #a31515;">"HttpHandler.ashx?ID="</span> + Session[<span style="color: #a31515;">"UserSessionID"</span>].ToString();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">protected</span> <span style="color: blue;">void</span>
UploadButton_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (FileUploadControl.HasFile)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">try</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">string</span> ext
= System.IO.<span style="color: #2b91af;">Path</span>.GetExtension(FileUploadControl.PostedFile.FileName);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
Session[<span style="color: #a31515;">"UserSessionID"</span>] =
Session[<span style="color: #a31515;">"UserSessionID"</span>] + ext;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
FileUploadControl.SaveAs(Server.MapPath(<span style="color: #a31515;">"~/"</span>)
+ Session[<span style="color: #a31515;">"UserSessionID"</span>]);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> StatusLabel.Text = <span style="color: #a31515;">"Upload status: File uploaded!"</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
ProfilePic.ImageUrl = <span style="color: #a31515;">"HttpHandler.ashx?ID="</span>
+ Session[<span style="color: #a31515;">"UserSessionID"</span>].ToString();<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">catch</span> (<span style="color: #2b91af;">Exception</span>
ex)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
StatusLabel.Text = <span style="color: #a31515;">"Upload status: The
file could not be uploaded. The following error occured: "</span> +
ex.Message;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div>
<br />
<br />
<b>HttpHandler.ashx</b><br />
<br />
<div class="MsoNormal">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="background-color: yellow; font-family: Consolas; font-size: 9.5pt;"><%</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">@</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: maroon;">WebHandler</span>
<span style="color: red;">Language</span><span style="color: blue;">="C#"</span>
<span style="color: red;">Class</span><span style="color: blue;">="HttpHandler"</span>
<span style="background-color: yellow;">%></span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;">public</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">class</span> <span style="color: #2b91af;">HttpHandler</span> : <span style="color: #2b91af;">IHttpHandler</span>
{<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">void</span>
ProcessRequest(<span style="color: #2b91af;">HttpContext</span> context)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">string</span> imagePath = context.Request.QueryString[<span style="color: #a31515;">"ID"</span>];<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">// split the string on periods and read the last element,
this is to ensure we have</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">// the right ContentType if the file is named something
like "image1.jpg.png"</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
System.IO.<span style="color: #2b91af;">FileInfo</span> imageFile = <span style="color: blue;">new</span> System.IO.<span style="color: #2b91af;">FileInfo</span>(context.Request.PhysicalApplicationPath
+ imagePath); <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">bool</span> fileExists = imageFile.Exists;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (fileExists)<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
context.Response.ContentType = <span style="color: #a31515;">"image/"</span>
+ imageFile.Extension;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
context.Response.WriteFile(context.Server.MapPath(imagePath));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">else</span><o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
context.Response.ContentType = <span style="color: #a31515;">"image/jpeg"</span>;<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
context.Response.WriteFile(context.Server.MapPath(<span style="color: #a31515;">"NoImage.jpg"</span>));<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">
context.Response.Write(imagePath);<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<br /></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">bool</span>
IsReusable<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">get</span> { <span style="color: blue;">return</span> <span style="color: blue;">true</span>; }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div>
<div class="MsoNormal" style="margin-bottom: 0.0001pt;">
<span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div>
<div class="MsoNormal">
<br /></div>
</div>Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-34668645395608759182012-06-11T04:25:00.000-07:002012-06-11T04:25:04.821-07:00Best Practices for Speeding Up Your Web Site<div dir="ltr" style="text-align: left;" trbidi="on">
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;">Today I found a greate article for best practices for making web pages fast.The list includes 34 best practices divided into 7 categories.</span><br />
<br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> 1) Content</span><br />
<br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Minimize HTTP Requests</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Reduce DNS Lookups</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Avoid Redirects</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Make Ajax Cacheable</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Post-load Components</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Preload Components</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Reduce the Number of DOM Elements</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Split Components Across Domains</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Minimize the Number of iframes</span><br />
<br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;">2) Server</span><br />
<br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Use a Content Delivery Network</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Add an Expires or a Cache-Control Header</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Gzip Components</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Configure ETags</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Flush the Buffer Early</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Use GET for AJAX Requests</span><br />
<br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;">3) CSS</span><br />
<br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Put Stylesheets at the Top</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Avoid CSS Expressions</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Choose over @import</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Avoid Filters</span><br />
<br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;">4) Javascript</span><br />
<br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Put Scripts at the Bottom</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Make JavaScript and CSS External</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Minify JavaScript and CSS</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Remove Duplicate Scripts</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Minimize DOM Access</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Develop Smart Event Handlers</span><br />
<br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;">5) Cookie</span><br />
<br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Reduce Cookie Size</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Use Cookie-free Domains for Components</span><br />
<br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;">6) Images</span><br />
<br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Optimize Images</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Optimize CSS Sprites</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Don’t Scale Images in HTML</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Make favicon.ico Small and Cacheable</span><br />
<br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;">7) Mobile</span><br />
<br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Keep Components under 25K</span><br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> * Pack Components into a Multipart Document</span><br />
<br />
<span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;">For details check out </span><a href="http://developer.yahoo.com/performance/rules.html" style="background-color: white; color: #336699; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;" target="_blank">this</a><span style="background-color: white; color: #333333; font-family: Verdana, Arial, sans-serif; font-size: 13px; line-height: 16px;"> </span>
</div>Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-88027801360427410462012-06-11T03:46:00.000-07:002012-06-11T03:47:17.371-07:00Create TextBox Dynamically using jQuery and Read Control Value In Code Behind - ASP.NET<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<pre class="csharpcode" style="background-color: white; font-family: Consolas, 'Courier New', Courier, monospace; font-size: 13px; line-height: 16px; text-align: justify;"><span class="asp" style="background-color: yellow;"><%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %></span>
<span class="kwrd" style="color: blue;"><!</span><span class="html" style="color: maroon;">DOCTYPE</span> <span class="attr" style="color: red;">html</span> <span class="attr" style="color: red;">PUBLIC</span> <span class="kwrd" style="color: blue;">"-//W3C//DTD XHTML 1.0 Transitional//EN"</span> <span class="kwrd" style="color: blue;">"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">html</span> <span class="attr" style="color: red;">xmlns</span><span class="kwrd" style="color: blue;">="http://www.w3.org/1999/xhtml"</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">head</span> <span class="attr" style="color: red;">runat</span><span class="kwrd" style="color: blue;">="server"</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">title</span><span class="kwrd" style="color: blue;">></</span><span class="html" style="color: maroon;">title</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">script</span> <span class="attr" style="color: red;">src</span><span class="kwrd" style="color: blue;">="Scripts/jquery-1.3.2.js"</span> <span class="attr" style="color: red;">type</span><span class="kwrd" style="color: blue;">="text/javascript"</span><span class="kwrd" style="color: blue;">></</span><span class="html" style="color: maroon;">script</span><span class="kwrd" style="color: blue;">></span>
<script type=<span class="str" style="color: #a31515;">"text/javascript"</span>>
$(document).ready(<span class="kwrd" style="color: blue;">function</span>() {
$(<span class="str" style="color: #a31515;">"#btnOfficial"</span>).click(<span class="kwrd" style="color: blue;">function</span>() {
<span class="kwrd" style="color: blue;">var</span> hdValue = $(<span class="str" style="color: #a31515;">"#theValue"</span>);
<span class="kwrd" style="color: blue;">var</span> num = ($(<span class="str" style="color: #a31515;">"#theValue"</span>).val() - 1) + 2;
hdValue.val(num);
<span class="kwrd" style="color: blue;">var</span> newDiv = $(document.createElement(<span class="str" style="color: #a31515;">'div'</span>)).attr(<span class="str" style="color: #a31515;">"id"</span>, <span class="str" style="color: #a31515;">'my'</span> + num + <span class="str" style="color: #a31515;">'Div'</span>);
newDiv.after().html(<span class="str" style="color: #a31515;">'<input type="text" name="TextBox'</span> + num + <span class="str" style="color: #a31515;">'" value="TextBox'</span> + num + <span class="str" style="color: #a31515;">'" >'</span>);
newDiv.appendTo(<span class="str" style="color: #a31515;">"#Div1"</span>);
});
});
<span class="kwrd" style="color: blue;"></</span><span class="html" style="color: maroon;">script</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"></</span><span class="html" style="color: maroon;">head</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">body</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">form</span> <span class="attr" style="color: red;">id</span><span class="kwrd" style="color: blue;">="form1"</span> <span class="attr" style="color: red;">runat</span><span class="kwrd" style="color: blue;">="server"</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">div</span> <span class="attr" style="color: red;">id</span><span class="kwrd" style="color: blue;">="Div1"</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"></</span><span class="html" style="color: maroon;">div</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">asp:GridView</span> <span class="attr" style="color: red;">ID</span><span class="kwrd" style="color: blue;">="GridView1"</span> <span class="attr" style="color: red;">runat</span><span class="kwrd" style="color: blue;">="server"</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"></</span><span class="html" style="color: maroon;">asp:GridView</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">input</span> <span class="attr" style="color: red;">type</span><span class="kwrd" style="color: blue;">="button"</span> <span class="attr" style="color: red;">id</span><span class="kwrd" style="color: blue;">="btnOfficial"</span> <span class="attr" style="color: red;">value</span><span class="kwrd" style="color: blue;">="Add Another TextBox"</span> <span class="kwrd" style="color: blue;">/></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">input</span> <span class="attr" style="color: red;">type</span><span class="kwrd" style="color: blue;">="hidden"</span> <span class="attr" style="color: red;">value</span><span class="kwrd" style="color: blue;">="1"</span> <span class="attr" style="color: red;">id</span><span class="kwrd" style="color: blue;">="theValue"</span> <span class="attr" style="color: red;">runat</span><span class="kwrd" style="color: blue;">="server"</span> <span class="kwrd" style="color: blue;">/></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">asp:Button</span> <span class="attr" style="color: red;">ID</span><span class="kwrd" style="color: blue;">="btnSave"</span> <span class="attr" style="color: red;">runat</span><span class="kwrd" style="color: blue;">="server"</span> <span class="attr" style="color: red;">Text</span><span class="kwrd" style="color: blue;">="Read"</span> <span class="attr" style="color: red;">OnClick</span><span class="kwrd" style="color: blue;">="btnSave_Click"</span> <span class="kwrd" style="color: blue;">/></span>
<span class="kwrd" style="color: blue;"></</span><span class="html" style="color: maroon;">form</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"></</span><span class="html" style="color: maroon;">body</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"></</span><span class="html" style="color: maroon;">html</span><span class="kwrd" style="color: blue;">></span>
</pre>
<pre class="csharpcode" style="background-color: white; font-family: Consolas, 'Courier New', Courier, monospace; font-size: 13px; line-height: 16px; text-align: justify;"><span class="kwrd" style="color: blue;">using</span> System;
<span class="kwrd" style="color: blue;">using</span> System.Collections.Generic;
<span class="kwrd" style="color: blue;">using</span> System.Linq;
<span class="kwrd" style="color: blue;">using</span> System.Web;
<span class="kwrd" style="color: blue;">using</span> System.Web.UI;
<span class="kwrd" style="color: blue;">using</span> System.Web.UI.WebControls;
<span class="kwrd" style="color: blue;">using</span> System.Collections;
<span class="kwrd" style="color: blue;">public</span> <span class="kwrd" style="color: blue;">partial</span> <span class="kwrd" style="color: blue;">class</span> _Default : System.Web.UI.Page
{
<span class="kwrd" style="color: blue;">protected</span> <span class="kwrd" style="color: blue;">void</span> Page_Load(<span class="kwrd" style="color: blue;">object</span> sender, EventArgs e)
{
}
<span class="kwrd" style="color: blue;">protected</span> <span class="kwrd" style="color: blue;">void</span> btnSave_Click(<span class="kwrd" style="color: blue;">object</span> sender, EventArgs e)
{
List<<span class="kwrd" style="color: blue;">string</span>> alForm = <span class="kwrd" style="color: blue;">new</span> List<<span class="kwrd" style="color: blue;">string</span>>();
<span class="rem" style="color: green;">//Textbox id is started</span>
<span class="rem" style="color: green;">// with 2 like(TextBox2,TextBox3.....</span>
<span class="kwrd" style="color: blue;">for</span> (<span class="kwrd" style="color: blue;">int</span> i = 2; i < Request.Form.Count - 2; i++)
{
<span class="kwrd" style="color: blue;">string</span> strId = <span class="str" style="color: #a31515;">"TextBox"</span> + i.ToString();
<span class="kwrd" style="color: blue;">string</span> strValue = Request.Form[strId].ToString();
alForm.Add(strValue);
strValue = <span class="str" style="color: #a31515;">""</span>;
}
<span class="rem" style="color: green;">//Uncomment this line and test.</span>
<span class="rem" style="color: green;">//foreach (string x in Request.Form)</span>
<span class="rem" style="color: green;">//{</span>
<span class="rem" style="color: green;">// string strValue = Request.Form[x].ToString();</span>
<span class="rem" style="color: green;">// alForm.Add(strValue);</span>
<span class="rem" style="color: green;">//}</span>
GridView1.DataSource = alForm;
GridView1.DataBind();
}
}</pre>
</div>Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-51907923066190976292012-06-10T01:38:00.000-07:002012-06-10T01:38:05.503-07:00Back Button Problem Solved using ASP.NET Cache<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="background-color: white; border: 0px; font-family: Arial, sans-sarif, serif; font-size: 12px; line-height: 20px; margin-bottom: 1em; outline: 0px; padding: 0px; text-align: -webkit-auto; vertical-align: baseline;">
A web browser's back button is essential for users to navigate across different web sites and web pages. However, for certain data sensitive web applications, using a web browser's back button can have unexpected and undesirable results. With poor planning, it could even crash a web site.</div>
<div style="background-color: white; border: 0px; font-family: Arial, sans-sarif, serif; font-size: 12px; line-height: 20px; margin-bottom: 1em; outline: 0px; padding: 0px; text-align: -webkit-auto; vertical-align: baseline;">
Take the following scenario as an example:</div>
<div style="background-color: white; border: 0px; font-family: Arial, sans-sarif, serif; font-size: 12px; line-height: 20px; margin-bottom: 1em; outline: 0px; padding: 0px; text-align: -webkit-auto; vertical-align: baseline;">
You developed a web survey for users to complete. Once the survey is submitted, the response is recorded in a database with a pre-coded caseID. Now, suppose a user just submitted his survey, then for some reason, he hit the browser's back button. Then, with or without making any changes, he submitted the survey again. Here, you ended up with two records (duplicate or not) with the same caseID. If the caseID is set to be unique, the user would get an error message.</div>
<div style="background-color: white; border: 0px; font-family: Arial, sans-sarif, serif; font-size: 12px; line-height: 20px; margin-bottom: 1em; outline: 0px; padding: 0px; text-align: -webkit-auto; vertical-align: baseline;">
In fact, the back button problem has pestered programmers for so long and caused so many headaches that across the net there is a flurry of questions, such as "How do I disable a browser's back button?".</div>
<div style="background-color: white; border: 0px; font-family: Arial, sans-sarif, serif; font-size: 12px; line-height: 20px; margin-bottom: 1em; outline: 0px; padding: 0px; text-align: -webkit-auto; vertical-align: baseline;">
Unfortunately, it is not possible to disable a browser's back button. Nor is it a good idea to do so. However, viable and simple solutions to get rid of this annoyance do exist.</div>
<div style="background-color: white; border: 0px; font-family: Arial, sans-sarif, serif; font-size: 12px; line-height: 20px; margin-bottom: 1em; outline: 0px; padding: 0px; text-align: -webkit-auto; vertical-align: baseline;">
The following is how you code it in a Class ASP way:</div>
<div style="background-color: white; border: 0px; font-family: Arial, sans-sarif, serif; font-size: 12px; line-height: 20px; margin-bottom: 1em; outline: 0px; padding: 0px; text-align: -webkit-auto; vertical-align: baseline;">
</div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 22.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";"><%</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EEEEEE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 22.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Response</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Buffer</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">=</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">True</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 22.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Response</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">ExpiresAbsolute</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">=</span><span style="font-family: 'Courier New'; font-size: 9pt;">
</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Now</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">()</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">-</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #006666; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">1</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EEEEEE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 22.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Response</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Expires</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">=</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #006666; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">0</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 22.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Response</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">CacheControl</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">=</span><span style="font-family: 'Courier New'; font-size: 9pt;">
</span><span style="color: #008800; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"no-cache"</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EEEEEE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 22.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;">%></span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<br />
<div style="background-color: white; border: 0px; font-family: Arial, sans-sarif, serif; font-size: 12px; line-height: 20px; margin-bottom: 1em; outline: 0px; padding: 0px; text-align: -webkit-auto; vertical-align: baseline;">
This code snippet basically directs the page in concern to expire immediately once it is posted and set the page to cache none of its content. In ASP .NET, you can do something similar to disable browser page caching, like the following:
</div>
<div style="background-color: white; border: 0px; font-family: Arial, sans-sarif, serif; font-size: 12px; line-height: 20px; margin-bottom: 1em; outline: 0px; padding: 0px; text-align: -webkit-auto; vertical-align: baseline;">
</div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Response</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Cache</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">SetCacheability</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">HttpCacheability</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">NoCache</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">);</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Response</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Cache</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">SetExpires</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Now</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">AddSeconds</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(-</span><span style="color: #006666; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">1</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">));</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Response</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Cache</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">SetNoStore</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">();</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: .25in; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Response</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">AppendHeader</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: #008800; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"Pragma"</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">,</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #008800; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"no-cache"</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">);</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<br />
<div style="background-color: white; border: 0px; font-family: Arial, sans-sarif, serif; font-size: 12px; line-height: 20px; margin-bottom: 1em; outline: 0px; padding: 0px; text-align: -webkit-auto; vertical-align: baseline;">
</div>
<div style="border: 0px; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline;">
You can place the code in the page_load event. Ideally, the code should be executed whenever the page is loaded. And, whenever a user tries to go back to the page, he/she should get a "Page has Expired" warning.</div>
<div style="border: 0px; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline;">
However, some browsers may ignore the page cache settings and some users may still get away with submitting a form multiple times. This leads us to a second, more reliable solution: the timestamp solution. You should always use this solution while also adding the response caching instructions to the Page_Load procedure.</div>
<div style="border: 0px; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline;">
Here is the code showing you how:</div>
<div style="border: 0px; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline;">
</div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">protected</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">void</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Page_Load</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">object</span><span style="font-family: 'Courier New'; font-size: 9pt;"> sender</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">,</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">EventArgs</span><span style="font-family: 'Courier New'; font-size: 9pt;"> e</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">)</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EEEEEE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">{</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Response</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Cache</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">SetCacheability</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">HttpCacheability</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">NoCache</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">);</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EEEEEE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Response</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Cache</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">SetExpires</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Now</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">AddSeconds</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(-</span><span style="color: #006666; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">1</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">));</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Response</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Cache</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">SetNoStore</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">();</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EEEEEE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Response</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">AppendHeader</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: #008800; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"Pragma"</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">,</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #008800; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"no-cache"</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">);</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<br /></div>
<div class="MsoNormal" style="background: #EEEEEE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">if</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Page</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">IsPostBack</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">){</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">if</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(</span><span style="font-family: 'Courier New'; font-size: 9pt;">isPageExpired</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">()){</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EEEEEE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Response</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Redirect</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: #008800; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"expired.htm"</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">);</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">}</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EEEEEE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">else</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">{</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Session</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: #008800; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"TimeStamp"</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">)</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">=</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Now</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">ToString</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">;</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EEEEEE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">ViewState</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: #008800; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"TimeStamp"</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">)</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">=</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Now</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">.</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">ToString</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">;</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">}</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EEEEEE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">}</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #880000; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//...........</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EEEEEE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #880000; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">//your own function
here</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">}</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EEEEEE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<br /></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">private</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">boolean</span><span style="font-family: 'Courier New'; font-size: 9pt;"> isPageExpired</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">()</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EEEEEE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">{</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">if</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Session</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: #008800; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"TimeStamp"</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">)</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">==</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">null</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">||</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EEEEEE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">ViewState</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: #008800; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"TimeStamp"</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">)</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">==</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">null</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">)</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">return</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">false</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">;</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EEEEEE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">else</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">if</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">Session</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: #008800; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"TimeStamp"</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">)</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">==</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #660066; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">ViewState</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">(</span><span style="color: #008800; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">"TimeStamp"</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">))</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">return</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">true</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">;</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EEEEEE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">else</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">return</span><span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #000088; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">false</span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">;</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<div class="MsoNormal" style="background: #EEEEEE; line-height: 15.0pt; margin-bottom: .0001pt; margin-bottom: 0in; margin-left: 13.5pt; margin-right: 12.0pt; margin-top: 0in; vertical-align: baseline;">
<span style="font-family: 'Courier New'; font-size: 9pt;"> </span><span style="color: #666600; font-family: "Courier New"; font-size: 9.0pt; mso-bidi-font-size: 11.0pt; mso-fareast-font-family: "Times New Roman";">}</span><span style="font-family: 'Courier New'; font-size: 9pt;"><o:p></o:p></span></div>
<br />
<div style="border: 0px; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline;">
</div>
<div style="border: 0px; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline;">
</div>
<div style="border: 0px; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline;">
The code is pretty self-explanatory. Whenever a page is loaded, it checks whether it is a resubmitted one by calling the isPageExpired function. If the function returns true, it redirects the page to the page-expired response; if not, it sets two timestamps: one saved in session state, the other view state.</div>
<div style="border: 0px; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline;">
The isPageExpired function compares the timestamp saved in session state and the timestamp in viewstate. If they are different, the user has submitted a form from cache; then, the page directs them to the Page-expired response.</div>
<div style="border: 0px; margin-bottom: 1em; outline: 0px; padding: 0px; vertical-align: baseline;">
So here it is, two simple solutions to the back-button problem.</div>
<br />
<br />
<br />
</div>Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-5150762685702224152011-10-31T01:32:00.000-07:002011-10-31T05:38:01.030-07:00How Many DAYS Old Are You?<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
</div>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.dailywritingtips.com/wp-content/uploads/2007/07/rulesforwritingnumbers.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="247" src="http://www.dailywritingtips.com/wp-content/uploads/2007/07/rulesforwritingnumbers.gif" width="320" /></a></div>
<br />
<br />
It always been fun playing with numbers. And when these numbers are about your birth
date, it becomes even more interesting. So I thought to write a post about having
fun with your birth date.<br />
<br />
Have you ever wondered, how many days old are you? When you will be 10,000 days
old? or when will be your 11111st day on earth?<br />
<br />
Now it become easier, put your birthday in the textbox and desired day in the other,
you will know the details as you want.<br />
<br />
Have fun!<br />
<br />
<br /></div>
<script language="JavaScript">
<!--
function lifetimer() {
today = new Date();
BirthDay = new Date(document.getElementById('age').value);
//alert(BirthDay);
kdays = document.getElementById('kdays').value;
if (isNaN(kdays)) { kdays = 0; }
msPerDay = 24 * 60 * 60 * 1000;
timeold = (today.getTime() - BirthDay.getTime());
e_daysold = timeold / msPerDay;
daysold = Math.floor(e_daysold);
//kdays = Math.floor(daysold / 1000) + 1;
//nextk = BirthDay.getTime() + (1000 * kdays * msPerDay);
nextk = BirthDay.getTime() + (kdays * msPerDay);
nextkdate = new Date(nextk);
document.getElementById('time1').value = daysold;
//document.live.kdays.value = kdays;
nextkyear = nextkdate.getYear();
if (nextkyear < 1900) nextkyear = nextkyear + 1900; //NS requires this adjustment
nextkString = 1 + nextkdate.getMonth() + "/" + nextkdate.getDate() + "/" + nextkyear;
if (kdays < 1) nextkString = "";
document.getElementById('kdate').value = nextkString;
return false;
}
//-->
</script>
<br />
<div align="center">
<table align="center" bgcolor="#CCCCCC" border="0" cellpadding="5">
<tbody>
<tr>
<td class="center">Enter date of birth in format mm/dd/yyyy: <input class="form" id="age" maxlength="25" name="age" size="10" type="text" value="12/31/1999" />
<input class="form" name="start1" onclick="javascript:return lifetimer();" type="button" value="GO!" />
</td>
</tr>
<tr>
<td class="center" nowrap="">You are
<input class="form" id="time1" maxlength="256" name="time1" size="6" type="text" value=" " />
days old today.
</td>
</tr>
<tr>
<td class="center" nowrap="">You will be
<input id="kdays" name="kdays" size="7" type="text" value="Enter Days" />
days old on
<input id="kdate" name="kdate" size="10" type="text" /><br />
<small> Enter number</small>
</td>
</tr>
</tbody>
</table>
</div>
<br />
<div align="center">
<br /></div>
</div>Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-81885539674265217302011-09-07T02:14:00.000-07:002011-09-07T03:37:06.124-07:00Panasonic Shows Off 3D Lumix Camera Prototype<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://i.i.com.com/cnwk.1d/i/tim/2011/09/02/IFA_Panasonic_3D_Lumix_20110902_002_610x402.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="blank"><img border="0" height="262" src="http://i.i.com.com/cnwk.1d/i/tim/2011/09/02/IFA_Panasonic_3D_Lumix_20110902_002_610x402.jpg" width="400" /></a></div>
<span class="Apple-style-span" style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: xx-small;">Panasonic
showed this prototype compact Lumix camera for shooting 3D photos and videos.
The zoom lens runs from the equivalent of 25-100mm, with an aperture range of
f3.9 to f5.7.</span><br />
<span class="apple-style-span"><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif; line-height: 115%;"><span class="Apple-style-span" style="font-size: xx-small;">(Credit: Stephen Shankland/CNET)</span></span></span><span style="background-attachment: initial; background-clip: initial; background-color: #2e2e30; background-image: initial; background-origin: initial; border-bottom-color: windowtext; border-bottom-style: none; border-bottom-width: 1pt; border-left-color: windowtext; border-left-style: none; border-left-width: 1pt; border-right-color: windowtext; border-right-style: none; border-right-width: 1pt; border-top-color: windowtext; border-top-style: none; border-top-width: 1pt; padding-bottom: 0in; padding-left: 0in; padding-right: 0in; padding-top: 0in;"><br /><span class="Apple-style-span" style="background-color: white; color: #333333; font-family: Arial, sans-serif; font-size: 15px;"><br /></span></span><br />
<span class="Apple-style-span" style="color: #333333; font-family: Arial, sans-serif;"></span><br />
<div style="margin-bottom: .0001pt; margin: 0in; vertical-align: baseline;">
<span class="Apple-style-span" style="color: #333333; font-family: Arial, sans-serif;"><span class="apple-style-span"><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif; font-size: 11pt;">BERLIN--Panasonic has offered high-end 3D videocameras as
part of its effort to advance the premium technology, but now it's begun
showing off a prototype for a 3D model from its Lumix line of still cameras.<o:p></o:p></span></span></span></div>
<div style="margin-bottom: .0001pt; margin: 0in; vertical-align: baseline;">
<span class="Apple-style-span" style="color: #333333; font-family: Arial, sans-serif;"><span class="apple-style-span"><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif; font-size: 11pt;"><br /></span></span></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span class="apple-style-span"><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif;">"We
are also developing a 3D compact camera for this winter," Takuya Sugita,
vice president of Panasonic's AVC Networks Company, said here this week at a
press conference at the <a href="http://news.cnet.com/8301-1035_3-20099931-94/ifa-2011-gadgets-galore-in-berlin-roundup/" target="blank"><span style="color: #333333; text-decoration: none;">IFA electronics
show</span></a>, which officially starts today. The company showed two
prototypes under glass at the show.<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: 0.0001pt; text-align: right; vertical-align: baseline;">
<span class="apple-style-span"><b><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif;"><a href="http://news.cnet.com/2300-17938_105-10009266.html" target="blank"><span style="color: #333333; text-decoration: none;">Panasonic's 3D
Lumix camera prototype (photos)</span></a><o:p></o:p></span></b></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><span id="goog_1262184935"></span><span id="goog_1262184940"></span><span id="goog_1262184943"></span><span id="goog_1262184944"></span><span id="goog_1262184941"></span><span id="goog_1262184936"></span></span><span style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></span><span style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></span><span style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://i.i.com.com/cnwk.1d/i/tim/2011/09/02/IFA_Panasonic_3D_Lumix_20110902_005_540x389.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;" target="blank"><img border="0" src="http://i.i.com.com/cnwk.1d/i/tim/2011/09/02/IFA_Panasonic_3D_Lumix_20110902_005_88x66.jpg" /></a><a href="http://i.i.com.com/cnwk.1d/i/tim/2011/09/02/IFA_Panasonic_3D_Lumix_20110902_004_540x503.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;" target="blank"><img border="0" src="http://i.i.com.com/cnwk.1d/i/tim/2011/09/02/IFA_Panasonic_3D_Lumix_20110902_004_88x66.jpg" /></a><a href="http://i.i.com.com/cnwk.1d/i/tim/2011/09/02/IFA_Panasonic_3D_Lumix_20110902_002_610x402.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;"><img border="0" src="http://i.i.com.com/cnwk.1d/i/tim/2011/09/02/IFA_Panasonic_3D_Lumix_20110902_002_88x66.jpg" target="blank" /></a><a href="http://i.i.com.com/cnwk.1d/i/tim/2011/09/02/IFA_Panasonic_3D_Lumix_20110902_003_540x284.jpg" imageanchor="1" style="clear: right; float: right; margin-bottom: 1em; margin-left: 1em;" target="blank"><img border="0" src="http://i.i.com.com/cnwk.1d/i/tim/2011/09/02/IFA_Panasonic_3D_Lumix_20110902_003_88x66.jpg" /></a></div>
<span class="apple-style-span"><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif;">The
company has offered a <a href="http://news.cnet.com/8301-17938_105-20099466-1/panasonic-wants-everyone-to-capture-3d-video/" target="blank"><span style="color: #333333; text-decoration: none;">couple tidbits
about the coming 3D Lumix camera</span></a>: it will have twin 4X zoom lenses
with folding optics and optical image stabilization for both video and still
images. It also will offer "simultaneous photo and video," Panasonic
said.<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span class="apple-style-span"><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif;">The
prototypes show a bit more, though not much in the way of surprises--check the <a href="http://news.cnet.com/2300-17938_105-10009266.html" target="blank"><span style="color: #333333; text-decoration: none;">3D Lumix
prototype slideshow</span></a> for some detailed views. The zoom lens runs
from the equivalent of 25-100mm, with an aperture range of f3.9 to f5.7.<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span class="apple-style-span"><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif;">On one
side is an HDMI output, and on the top are stereo microphones. It also features
a built-in flash and a red button for recording video. Underneath is a tripod
mount and a slot for a battery and SDXC card.<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span class="apple-style-span"><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif;">It will
apparently record video in AVCHD, Panasonic's favorite encoding technology also
known by the name H.264. Presumably it will use the new 3D version of the
technology.<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span class="apple-style-span"><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif;">The
entire consumer electronics industry is moving to 3D technology, chiefly with
TVs. The technology can offer a more immersive experience--and gives companies
something new to sell now that the transition from CRTs to flat-panel TVs is no
longer such a strong market.<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<br /></div>
<div class="separator" style="clear: both; text-align: center;">
</div>
<span class="apple-style-span"><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif; font-size: 11pt; line-height: 115%;">Panasonic is among the companies that hope
people will create 3D content as well. 3D cameras and videocameras also offer
an opportunity to sell premium products that might have a better chance of
standing out above the crowd.</span></span></div>
Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-36130263746899516782011-09-06T23:49:00.000-07:002011-09-06T23:50:11.926-07:00Is mind control the future for TeleVisions?<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.shinyshiny.tv/Wii_head_remote-thumb-383x312.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="260" src="http://www.shinyshiny.tv/Wii_head_remote-thumb-383x312.jpg" width="320" /></a></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span class="apple-style-span"><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif;"><br /></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span class="apple-style-span"><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif;">China-based
Haier is showcasing an interesting mind control technology for TVs at the
ongoing <a href="http://news.cnet.com/8301-1035_3-20099931-94/ifa-2011-gadgets-galore-in-berlin-roundup/" target="_blank"><span style="color: #333333; text-decoration: none;">IFA trade show</span></a> in
Berlin. The Brain Wave resembles a headset, with an extension placed peculiarly
on the user's forehead to control a TV's volume and change channels with
thoughts alone. The firm demonstrated its prototype with a game that involves
blowing up barrels with your mind. Even if Haier gets the system to market for
TVs, we're betting it won't be easy to convince most consumers to don the bulky
headset in its present form.<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span class="apple-style-span"><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif;">Having
said that, we would love to see the Brain Wave miniaturized and made more
comfortable, or possibly integrated into regular 3D glasses. Until then, there
are other, less intrusive alternatives to remote controls ranging from voice
recognition to <a href="http://www.codeshode.com/2011/09/canesta-brings-gesture-control-to-tvs.html" target="_blank"><span style="color: #333333; text-decoration: none;">hand gestures</span></a>.<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span class="apple-style-span"><i><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif;">(Source: <a href="http://asia.cnet.com/crave/is-mind-control-the-future-for-tvs-62210751.htm" target="_blank"><span style="color: #333333; text-decoration: none;">Crave Asia</span></a> via <a href="http://www.engadget.com/2011/09/03/haiers-mind-control-tv-prototype-hits-ifa-we-go-foreheads-on/" target="_blank"><span style="color: #333333; text-decoration: none;">Engadget</span></a>)</span></i></span><i> <o:p></o:p></i></div>
</div>
Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-17238720784504041862011-09-06T23:40:00.000-07:002011-09-06T23:41:21.940-07:00Canesta brings gesture control to TVs and more<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9g6-q2mdBevNyC4st-kwShnb1KPmuAaqNDIIT5_vlH4riTQv4eq5uTbF-l2abj3LywXFljh55REF3Soema365SkNJFw6hQNL_Hodv-ynjflunVM6wsQjLAhBa3vQTkFKPnT4B-S3h7uE/s1600/Canesta.png" imageanchor="1" style="clear: left; float: left; margin-bottom: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9g6-q2mdBevNyC4st-kwShnb1KPmuAaqNDIIT5_vlH4riTQv4eq5uTbF-l2abj3LywXFljh55REF3Soema365SkNJFw6hQNL_Hodv-ynjflunVM6wsQjLAhBa3vQTkFKPnT4B-S3h7uE/s1600/Canesta.png" /></a></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span class="apple-style-span"><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif;">The
below video shows <span style="color: #333333; text-decoration: none;"><b>Canesta's</b></span> new
3D gesture control system, which it's hoping to sell soon with help from
Hitachi and GestureTek. The idea is to build the sensors into media devices
such as game consoles or Apple TV-like gear to give your remote control a rest.<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span class="apple-style-span"><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif;">It's a
pretty cool idea, and according to the accompanying <span style="color: #333333; text-decoration: none;">press release</span>,
it should be a low-cost product. We're not sure when--if ever--this will make
its way into living rooms, but the know-how is there. If this Canesta video and
Microsoft's E3 announcements prove anything it's that the technology is ready,
too.</span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span class="apple-style-span"><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif;"><br /></span></span></div>
<div class="separator" style="clear: both; text-align: center;">
<iframe allowfullscreen='allowfullscreen' webkitallowfullscreen='webkitallowfullscreen' mozallowfullscreen='mozallowfullscreen' width='320' height='266' src='https://www.youtube.com/embed/uR27dPHI7dQ?feature=player_embedded' frameborder='0'></iframe></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<br /></div>
</div>
Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-39980981065045204702011-09-01T03:54:00.000-07:002012-06-11T03:54:41.363-07:00Add Copy to Clipboard Button using Javascript<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<pre class="csharpcode" style="background-color: white; font-family: Consolas, 'Courier New', Courier, monospace; font-size: 13px; line-height: 16px; text-align: justify;"><span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">html</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">head</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"></</span><span class="html" style="color: maroon;">head</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">body</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">textarea</span> <span class="attr" style="color: red;">id</span><span class="kwrd" style="color: blue;">='clipText'</span><span class="kwrd" style="color: blue;">></span>
Enter Text And Click Button To Copy Text To ClipBoard<span class="kwrd" style="color: blue;"></</span><span class="html" style="color: maroon;">textarea</span><span class="kwrd" style="color: blue;">><</span><span class="html" style="color: maroon;">br</span> <span class="kwrd" style="color: blue;">/></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">input</span> <span class="attr" style="color: red;">type</span><span class="kwrd" style="color: blue;">="button"</span> <span class="attr" style="color: red;">id</span><span class="kwrd" style="color: blue;">='bt'</span> <span class="attr" style="color: red;">onclick</span><span class="kwrd" style="color: blue;">="clipboardData.setData('Text',document.getElementById('clipText').value);"</span>
<span class="attr" style="color: red;">value</span><span class="kwrd" style="color: blue;">="Copy"</span> <span class="kwrd" style="color: blue;">/></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">input</span> <span class="attr" style="color: red;">type</span><span class="kwrd" style="color: blue;">="button"</span> <span class="attr" style="color: red;">onclick</span><span class="kwrd" style="color: blue;">="clipboardData.clearData('Text');"</span> <span class="attr" style="color: red;">value</span><span class="kwrd" style="color: blue;">="Clear"</span> <span class="kwrd" style="color: blue;">/></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">input</span> <span class="attr" style="color: red;">type</span><span class="kwrd" style="color: blue;">="button"</span> <span class="attr" style="color: red;">onclick</span><span class="kwrd" style="color: blue;">="alert(clipboardData.getData('Text'));"</span> <span class="attr" style="color: red;">value</span><span class="kwrd" style="color: blue;">="Paste"</span> <span class="kwrd" style="color: blue;">/></span>
<span class="kwrd" style="color: blue;"></</span><span class="html" style="color: maroon;">body</span><span class="kwrd" style="color: blue;">></span></pre>
</div>Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-45531022496257796112011-08-23T04:10:00.000-07:002012-06-11T04:10:40.460-07:00Enable/Disable DropDownList through Checkbox using jQuery - ASP.NET<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<pre class="csharpcode" style="background-color: white; font-family: Consolas, 'Courier New', Courier, monospace; font-size: 13px; line-height: 16px;"><span class="asp" style="background-color: yellow;"><%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %></span>
<span class="kwrd" style="color: blue;"><!</span><span class="html" style="color: maroon;">DOCTYPE</span> <span class="attr" style="color: red;">html</span> <span class="attr" style="color: red;">PUBLIC</span> <span class="kwrd" style="color: blue;">"-//W3C//DTD XHTML 1.0 Transitional//EN"</span> <span class="kwrd" style="color: blue;">"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">html</span> <span class="attr" style="color: red;">xmlns</span><span class="kwrd" style="color: blue;">="http://www.w3.org/1999/xhtml"</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">head</span> <span class="attr" style="color: red;">runat</span><span class="kwrd" style="color: blue;">="server"</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">title</span><span class="kwrd" style="color: blue;">></</span><span class="html" style="color: maroon;">title</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">script</span> <span class="attr" style="color: red;">src</span><span class="kwrd" style="color: blue;">="Scripts/jquery-1.4.1.js"</span> <span class="attr" style="color: red;">type</span><span class="kwrd" style="color: blue;">="text/javascript"</span><span class="kwrd" style="color: blue;">></</span><span class="html" style="color: maroon;">script</span><span class="kwrd" style="color: blue;">></span>
<script type=<span class="str" style="color: #a31515;">"text/javascript"</span>>
$(document).ready(<span class="kwrd" style="color: blue;">function</span> () {
$(<span class="str" style="color: #a31515;">"#chkEnable"</span>).click(<span class="kwrd" style="color: blue;">function</span> () {
<span class="kwrd" style="color: blue;">if</span> (<span class="kwrd" style="color: blue;">this</span>.<span class="kwrd" style="color: blue;">checked</span>)
$(<span class="str" style="color: #a31515;">'#ddlList'</span>).attr(<span class="str" style="color: #a31515;">'disabled'</span>, <span class="str" style="color: #a31515;">'disabled'</span>);
<span class="kwrd" style="color: blue;">else</span>
$(<span class="str" style="color: #a31515;">'#ddlList'</span>).removeAttr(<span class="str" style="color: #a31515;">'disabled'</span>);
});
});
<span class="kwrd" style="color: blue;"></</span><span class="html" style="color: maroon;">script</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"></</span><span class="html" style="color: maroon;">head</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">body</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">form</span> <span class="attr" style="color: red;">id</span><span class="kwrd" style="color: blue;">="form1"</span> <span class="attr" style="color: red;">runat</span><span class="kwrd" style="color: blue;">="server"</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">div</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">asp:CheckBox</span> <span class="attr" style="color: red;">ID</span><span class="kwrd" style="color: blue;">="chkEnable"</span> <span class="attr" style="color: red;">runat</span><span class="kwrd" style="color: blue;">="server"</span> <span class="attr" style="color: red;">Text</span><span class="kwrd" style="color: blue;">="Enable/Disable"</span> <span class="kwrd" style="color: blue;">/><</span><span class="html" style="color: maroon;">br</span> <span class="kwrd" style="color: blue;">/></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">asp:DropDownList</span> <span class="attr" style="color: red;">ID</span><span class="kwrd" style="color: blue;">="ddlList"</span> <span class="attr" style="color: red;">runat</span><span class="kwrd" style="color: blue;">="server"</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">asp:ListItem</span> <span class="attr" style="color: red;">Text</span><span class="kwrd" style="color: blue;">="Select"</span> <span class="attr" style="color: red;">Value</span><span class="kwrd" style="color: blue;">="-1" /</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">asp:ListItem</span> <span class="attr" style="color: red;">Text</span><span class="kwrd" style="color: blue;">="Option1"</span> <span class="attr" style="color: red;">Value</span><span class="kwrd" style="color: blue;">="1"</span> <span class="kwrd" style="color: blue;">/></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">asp:ListItem</span> <span class="attr" style="color: red;">Text</span><span class="kwrd" style="color: blue;">="Option2"</span> <span class="attr" style="color: red;">Value</span><span class="kwrd" style="color: blue;">="2"</span> <span class="kwrd" style="color: blue;">/></span>
<span class="kwrd" style="color: blue;"><</span><span class="html" style="color: maroon;">asp:ListItem</span> <span class="attr" style="color: red;">Text</span><span class="kwrd" style="color: blue;">="Option3"</span> <span class="attr" style="color: red;">Value</span><span class="kwrd" style="color: blue;">="3"</span> <span class="kwrd" style="color: blue;">/></span>
<span class="kwrd" style="color: blue;"></</span><span class="html" style="color: maroon;">asp:DropDownList</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"></</span><span class="html" style="color: maroon;">div</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"></</span><span class="html" style="color: maroon;">form</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"></</span><span class="html" style="color: maroon;">body</span><span class="kwrd" style="color: blue;">></span>
<span class="kwrd" style="color: blue;"></</span><span class="html" style="color: maroon;">html</span><span class="kwrd" style="color: blue;">></span></pre>
</div>Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-10395131018750191182011-08-19T23:07:00.000-07:002011-09-06T23:51:42.040-07:00Dual OS Tablet : Windows and Android ViewPad 10Pro Tablet<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="http://www.viewsonic.com/assets/110/21615_350w279h.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;" target="_blank"><img border="0" src="http://www.viewsonic.com/assets/110/21615_350w279h.jpg" /></a></div>
<div>
<br />
<div class="MsoNormal" style="line-height: 15.6pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif; font-size: 9pt;">Here
finally is a tablet that can rid you of all the grouse that you may
have had so far of tablet PCs running Window. That too without having to give
up on Android. Welcome the new</span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: black; font-family: Arial, sans-serif; font-size: 9pt;"> <a href="http://www.viewsonic.com/products/vpad10.htm" target="_blank"><span style="border-bottom-color: windowtext; border-bottom-style: none; border-bottom-width: 1pt; border-left-color: windowtext; border-left-style: none; border-left-width: 1pt; border-right-color: windowtext; border-right-style: none; border-right-width: 1pt; border-top-color: windowtext; border-top-style: none; border-top-width: 1pt; color: #023565; padding-bottom: 0in; padding-left: 0in; padding-right: 0in; padding-top: 0in; text-decoration: none;">ViewPad 10Pro from ViewSonic</span></a> t</span><span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif; font-size: 9pt;">hat dual boots both Android and Windows. The 10
inch tablet with an Intel Atom Oak Trail processor was being showcased by
ViewSonic since early this year and now it seems its finally ready to hit the
streets.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.6pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<br /></div>
<div class="MsoNormal" style="line-height: 15.6pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif; font-size: 9pt;">One
of the biggest pluses with the <a href="http://goodereader.com/blog/tablet-slates/hands-on-review-of-the-viewsonic-viewpad-10pro-android-and-windows-tablet/" target="_blank"><span style="border-bottom-color: windowtext; border-bottom-style: none; border-bottom-width: 1pt; border-left-color: windowtext; border-left-style: none; border-left-width: 1pt; border-right-color: windowtext; border-right-style: none; border-right-width: 1pt; border-top-color: windowtext; border-top-style: none; border-top-width: 1pt; color: #023565; padding-bottom: 0in; padding-left: 0in; padding-right: 0in; padding-top: 0in; text-decoration: none;">ViewPad 10Pro</span></a> is its battery life that has gained a
degree of respectability, which in turn can be attributed to the use of Intel
Z670 Atom processor based on the Oak Trail platform with a clock speed of 1.5
GHz. Run-time is touted to be in the range of 8 hours on a single charge which
is a couple of hours more than what Wintel tablets are generally known for.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.6pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<br /></div>
<div class="MsoNormal" style="line-height: 15.6pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif; font-size: 9pt;">Another
big advantage of the ViewPad 10Pro is its ability to run both Android
and Windows application. Also, even though the tablet runs both the
Windows and Android operating systems, yet the device is not a dual boot one in
the truest sense since you won’t be required to reboot in order to switch
between the two OSs. Instead, a tap on an icon is all that is needed to switch
between the two. This since the base operating system is Windows with
Android running over it as a virtualized layer over Windows. ViewSonic
attributes this feature to the use of a software named BlueStacks.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.6pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<br /></div>
<div class="MsoNormal" style="line-height: 15.6pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif; font-size: 9pt;">As
for its specs, the ViewPad 10Pro comes with a 1024 X 600 pixel 10.1 inch screen
based on capacitive multitouch technology. The tablet includes a 2 GB RAM and
can support up to 32 GB of max storage capacity. For output the tablet has HDMI
out port and it can playback 1080p HD video. It also has support for
802.11b/g/n Wi-Fi and Bluetooth.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.6pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<br /></div>
<div class="MsoNormal" style="line-height: 15.6pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif; font-size: 9pt;">There
are two version of the tablet — one which runs Windows 7 Home Premium
and Android 2.3 and is priced at $599, while the other at $699 has a 32 GB SSD
running Windows 7 Professional along with Android 2.3 Gingerbread.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.6pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif; font-size: 9pt;">However,
the tablet still runs the risk of skitling out of public memory soon as the
world has moved on since the tablet was first announced. Its Windows 8 that we
are looking forward to and the new Windows version is making all the right
noises so far. Android too has made steady progress so that its the tablet
optimized Honeycomb version that is doing the rounds now and its Ice Cream
Sandwich that is next in the pipeline. But who knows, the tablet might be
upgradeable to both the new versions of Android and Windows.<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: 15.6pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif; font-size: 9pt;"><br /></span></div>
<div class="MsoNormal" style="line-height: 15.6pt; margin-bottom: .0001pt; margin-bottom: 0in; vertical-align: baseline;">
<span style="background-attachment: initial; background-clip: initial; background-color: white; background-image: initial; background-origin: initial; color: #333333; font-family: Arial, sans-serif; font-size: 9pt;">Source: </span><span class="Apple-style-span" style="line-height: normal;"><a href="http://www.viewsonic.com/products/vpad10.htm" target="_blank">http://www.viewsonic.com/products/vpad10.htm</a></span></div>
<div class="MsoNormal">
<br /></div>
</div>
</div>
Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-28949044256186990132011-08-16T23:07:00.000-07:002011-08-16T23:07:28.922-07:00Few Expectations from Windows 8<div dir="ltr" style="text-align: left;" trbidi="on">
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2J4VnfDM5sz0XP4f7N12gRHDXquzH1YALqwXG8rV7PNRrnXNuxOYFvq10qjsOmL0DAUayk0wqXIiFOk8_7dkJR2RRXKTMebjVYvrBEeaQQD_5qi_ZiWZ-qfZx86sCffSuqn-9vT95qnY/s1600/Windows-82-450x288.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="204" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi2J4VnfDM5sz0XP4f7N12gRHDXquzH1YALqwXG8rV7PNRrnXNuxOYFvq10qjsOmL0DAUayk0wqXIiFOk8_7dkJR2RRXKTMebjVYvrBEeaQQD_5qi_ZiWZ-qfZx86sCffSuqn-9vT95qnY/s320/Windows-82-450x288.jpg" width="320" /></a></div>
<span class="Apple-style-span" style="font-family: Tahoma, Arial, Helvetica, Geneva, sans-serif; font-size: 12px;"><br /></span><br />
<span class="Apple-style-span" style="font-family: Tahoma, Arial, Helvetica, Geneva, sans-serif; font-size: 12px;">I hope Microsoft does more than give a pretty facelift to match its smartphone OS. Among the things that have unnecessarily bedeviled PC users since the days of '95 we may count:<br /><br />- Plug & Play that doesn't. Few experiences are as frustrating as finding your new hardware isn't recognized properly by the system. If 8 can standardize minimum-spec code built in at the OS level to recognize the most commonly seen devices maybe we can finally kiss goodbye all those memories of unrecognized peripherals ruining your day.<br /><br />- Thin is in. As slick as Win 7 is each new build brings with it unnecessary baggage. The inclusion of ancient bundled apps like Paint is, simply put, an embarrassment. In an age when a modern linux distro can fit on a modest USB Windows is straining to fit onto DVDs. Make the next OS boot up in ten seconds flat and load secondary system files later as needed.<br /><br />- Easy networking and sharing. If I, a guy who's been in IT now for two decades, still get mortified when trying to interconnect computers how does that bode for grandma? Why is it that sharing my C drive is cloaked in umpteen security layers and then still cross-your-fingers and hope that it'll be useable on the other side?<br /><br />- Why does Windows expect me to do things its way? Every time I want to download a file it insists, despite thousands of repeated redirections to my desktop, to stick it in some nested document folder I never use. Why is it that my desktop icons so often switch places for no good reason? A 21st OS should adapt from my patterns of usage.<br /><br />- Stop being so greedy. Having a half dozen version of the same OS leads to confusion and ill-will. If you have to have multiple versions at all separate from consumer and server versions. That's it.<br /><br />- Go cloud. The MS business model is too tied to physical media and pay-per-license. I ditched Outlook years ago for Gmail because there was no such thing as an online version of it. Google docs, free for all, is tempting me to ditch Office for the same reason. How about an online backup service built into the OS so I don't have to rely on a 3rd party? This is an essential mission of any OS.<br /><br />- Innovation. I struggle to think of a single truly breakthrough Microsoft invention. Ok I take that back, let's give props for the Kinect. But in terms of OS for me to be wowed by Win 8 it has to have more substance than a gussied up GUI. I want to have a truly novel way of locating and organizing my files. I want to do what I want to do with speed and with the OS being invisible until I need it. I want more resiliency, not just stability, so that things don't stop working seemingly for the hell of it and, likewise, less dread thinking of what will go wrong when I plug in a new widget or install a new app. It'll be magic the day the whole thing just works without a too-long wait or too many nag screens or some other if and or but.<br /><br />Remember MS, Windows is an OPERATING SYSTEM. It should perform three core functions: connect the machine with its various parts and peripherals, provide a platform for software and file management. The company should concentrate on optimizing that core experience and recognize that the bundled apps are at best gravy and at worst bloatware that gets in the way.</span><br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivcOyWoCNTD67g8HTrLTXiKFlO8gyN8IVSFp3PUCw1NdfBhlDVh2hb6bzRw_4H4ktDoHB4PIx1O9xXvEZoBxJJUsSVlhRgmBEJ_v7D1onR4mA7OwfeR22XuM170zxSxY5NsUEaiYdS98A/s1600/windows-8.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="200" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEivcOyWoCNTD67g8HTrLTXiKFlO8gyN8IVSFp3PUCw1NdfBhlDVh2hb6bzRw_4H4ktDoHB4PIx1O9xXvEZoBxJJUsSVlhRgmBEJ_v7D1onR4mA7OwfeR22XuM170zxSxY5NsUEaiYdS98A/s200/windows-8.jpg" width="200" /></a></div>
<span class="Apple-style-span" style="font-family: Tahoma, Arial, Helvetica, Geneva, sans-serif; font-size: 12px;"><br /></span></div>
Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-60932643425298141472011-07-28T02:33:00.000-07:002011-07-29T05:31:55.741-07:00Split CSV String into Table in SQL Server<div dir="ltr" style="text-align: left;" trbidi="on">
<br />
<div style="margin-bottom: .0001pt; margin: 0in;">
<span style="color: black;">We all have some time bogged down into such situations where we require to update table from Comma/Character Separated Values.<o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0in;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0in;">
By default there is no function in SQL Server that can split comma separated string into Table (Rows). Following T-SQL is custom made function that can split CSV string into table.<span style="color: black;"><o:p></o:p></span></div>
<div style="margin-bottom: .0001pt; margin: 0in;">
<br /></div>
<div style="margin-bottom: .0001pt; margin: 0in;">
<span style="color: black;">Here is the function that will return table when passed CSV:<span class="Apple-style-span" style="font-size: medium;"><o:p></o:p></span></span></div>
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">CREATE</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">FUNCTION</span> dbo<span style="color: grey;">.</span>SplitCSV<span style="color: blue;"> </span><span style="color: grey;">(</span>@CSVString <span style="color: blue;">VARCHAR</span><span style="color: grey;">(</span>8000<span style="color: grey;">),</span> @Delimiter <span style="color: blue;">CHAR</span><span style="color: grey;">(</span>1<span style="color: grey;">))<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">RETURNS</span><span style="font-family: 'Courier New'; font-size: 10pt;"> @temptable <span style="color: blue;">TABLE </span><span style="color: grey;">(</span>items <span style="color: blue;">VARCHAR</span><span style="color: grey;">(</span>8000<span style="color: grey;">))<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">AS<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">BEGIN<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">DECLARE</span> @pos <span style="color: blue;">INT</span><span style="color: grey;">;<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">DECLARE</span> @slice <span style="color: blue;">VARCHAR</span><span style="color: grey;">(</span>8000<span style="color: grey;">);<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">SELECT</span> @pos <span style="color: grey;">=</span> 1<span style="color: grey;">;<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">IF</span> <span style="color: magenta;">LEN</span><span style="color: grey;">(</span>@CSVString<span style="color: grey;">)</span> <span style="color: grey;"><</span> 1 <span style="color: grey;">OR</span> @CSVString <span style="color: grey;">IS</span> <span style="color: grey;">NULL</span> <span style="color: blue;">RETURN</span><span style="color: grey;">;<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">WHILE</span> @pos<span style="color: grey;">!=</span> 0<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">BEGIN<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">SET</span> @pos <span style="color: grey;">=</span> <span style="color: magenta;">CHARINDEX</span><span style="color: grey;">(</span>@Delimiter<span style="color: grey;">,</span>@CSVString<span style="color: grey;">);<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">IF</span> @pos <span style="color: grey;">!=</span> 0<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">SET</span> @slice <span style="color: grey;">=</span> <span style="color: grey;">LEFT(</span>@CSVString<span style="color: grey;">,</span> @pos <span style="color: grey;">-</span> 1<span style="color: grey;">);<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">ELSE<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">SET</span> @slice <span style="color: grey;">=</span> @CSVString<span style="color: grey;">;<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">IF</span><span style="color: grey;">(</span> <span style="color: magenta;">LEN</span><span style="color: grey;">(</span>@slice<span style="color: grey;">)</span> <span style="color: grey;">></span> 0<span style="color: grey;">)<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">INSERT</span> <span style="color: blue;">INTO</span> @temptable<span style="color: grey;">(</span>Items<span style="color: grey;">)</span> <span style="color: blue;">VALUES </span><span style="color: grey;">(</span>@slice<span style="color: grey;">);<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">SET</span> @CSVString <span style="color: grey;">=</span> <span style="color: grey;">RIGHT(</span>@CSVString<span style="color: grey;">,</span> <span style="color: magenta;">LEN</span><span style="color: grey;">(</span>@CSVString<span style="color: grey;">)</span> <span style="color: grey;">-</span> @pos<span style="color: grey;">);<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">IF</span> <span style="color: magenta;">LEN</span><span style="color: grey;">(</span>@CSVString<span style="color: grey;">)</span> <span style="color: grey;">=</span> 0 <span style="color: blue;">BREAK</span><span style="color: grey;">;<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">END<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">RETURN<o:p></o:p></span></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">END<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">Usage:<o:p></o:p></span></div>
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;">
<br /></div>
<div class="MsoNormal">
<span style="color: blue; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">SELECT</span><span style="font-family: 'Courier New'; font-size: 10pt; line-height: 115%;"> <span style="color: grey;">*</span> <span style="color: blue;">FROM</span> dbo<span style="color: grey;">.</span>SplitCSV<span style="color: blue;"> </span><span style="color: grey;">(</span><span style="color: red;">'Computer,Keyboard,Mouse,USB'</span><span style="color: grey;">,</span> <span style="color: red;">','</span><span style="color: grey;">);</span></span><o:p></o:p></div>
<br />
<br />
<br />
Hope it helps!</div>
Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-30956020940917872162011-07-28T00:14:00.000-07:002011-07-28T02:51:10.850-07:00What Do You Love from Google - Insight<div dir="ltr" style="text-align: left;" trbidi="on"><span class="Apple-style-span" style="color: #474747; font-family: Arial, Helvetica, sans-serif; font-size: 13px; line-height: 17px;"></span><br />
<div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #474747; font-size: 13px; line-height: 21px; margin-bottom: 18px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">Google has launched a new, mysterious service called What Do You Love. It’s a simple search box, similar to the one on Google’s homepage, but it returns results from more than 20 different Google services, including Google Translate, Trends, YouTube, Maps and Groups.</div><div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #474747; font-size: 13px; line-height: 21px; margin-bottom: 18px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">The results are presented in little boxes that can, in some cases, be expanded by clicking on the icon in the lower right corner. If you need even more results, you can always click the button in the upper right corner of the box and go directly to the chosen service.</div><div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #474747; font-size: 13px; line-height: 21px; margin-bottom: 18px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">The concept reminds us of iGoogle, a service that lets you add simple apps to your own personalized portal. What Do You Love, however, instantly creates a mini-portal about any term you choose, which makes it a nice option for users who don’t have the time to tinker with options and simply want to have access to Google’s many services on one page.</div><div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #474747; font-size: 13px; line-height: 21px; margin-bottom: 18px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">The service, located on the address <a href="http://www.wdyl.com/" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #1e598e; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none; vertical-align: baseline;" target="_blank">www.wdyl.com</a> and <a href="http://google.com/whatdoyoulove/" style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #1e598e; font-size: 13px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; text-decoration: none; vertical-align: baseline;" target="_blank">google.com/whatdoyoulove</a>, bears Google’s copyright mark but very little explanation, and it hasn’t so far been announced on any of Google’s official blogs.<br />
<br />
<a name='more'></a></div><div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #474747; font-size: 13px; line-height: 21px; margin-bottom: 18px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;">Tell us how you like it in the comments.</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg16YqqtohfwAjdqgNa4FxttwwhdTKvG9yjMJSrPytbYxX9P6yf2zds5JnAJg2a8PVRvktWGVS56hV3St68BaTVC_BMBxW-PTlw0f0N6MBp9WqWpAXPDPZ_ZuRGsByVAFTLxPsjnPIXGso/s1600/What-do-you-love-google-code-shode.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg16YqqtohfwAjdqgNa4FxttwwhdTKvG9yjMJSrPytbYxX9P6yf2zds5JnAJg2a8PVRvktWGVS56hV3St68BaTVC_BMBxW-PTlw0f0N6MBp9WqWpAXPDPZ_ZuRGsByVAFTLxPsjnPIXGso/s1600/What-do-you-love-google-code-shode.png" /></a></div><div style="background-attachment: initial; background-clip: initial; background-color: transparent; background-image: initial; background-origin: initial; background-position: initial initial; background-repeat: initial initial; border-bottom-width: 0px; border-color: initial; border-left-width: 0px; border-right-width: 0px; border-style: initial; border-top-width: 0px; color: #474747; font-size: 13px; line-height: 21px; margin-bottom: 18px; margin-left: 0px; margin-right: 0px; margin-top: 0px; outline-color: initial; outline-style: initial; outline-width: 0px; padding-bottom: 0px; padding-left: 0px; padding-right: 0px; padding-top: 0px; vertical-align: baseline;"><br />
</div></div>Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-83582698379158828982011-07-26T04:26:00.000-07:002011-07-26T04:30:04.031-07:00How to Email a Web Page As HTML in ASP.NET using C# VB.NET<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on">This post explains <b>How to Email a Web Page As HTML From Your Site</b> or in fact any web page you want (though i would not recommend any with lots of scripts etc in it). It is very useful for email forms to customers etc from your site.<br />
<br />
Personally I create an plainer version of the form just for email. I remove any menu functions and other things that are there as part of the website and are not useful in the email - but that is a personal preference.<br />
<br />
<br />
I have already written a couple of posts regarding How to Send Email in ASP.NET. You can check them here:<br />
<br />
<ul style="text-align: left;"><li><a href="http://www.codeshode.com/2011/07/send-bulk-emails-using-c-vbnet-in.html">Send Bulk Emails using C# VB.NET in ASP.NET</a><a href="http://www.blogger.com/"></a></li>
<li><a href="http://www.codeshode.com/2010/06/send-email-with-attachment-in-aspnet.html">Send Email With Attachment in ASP.NET</a></li>
<li><a href="http://www.codeshode.com/2010/06/send-email-using-gmail-in-aspnet.html">Send Email Using Gmail in ASP.NET</a></li>
</ul><br />
<a name='more'></a><br />
<br />
However, to keep things simple, this is how an email could be send:<br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><b><u>C#</u></b></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"></span><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"> </span><br />
<div style="margin-bottom: .0001pt; margin: 0in;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span class="apple-style-span"><span style="color: blue; font-family: Consolas; font-size: 10pt;">using</span></span><span class="apple-converted-space"><span style="color: black; font-family: Consolas; font-size: 10pt;"> </span></span><span class="apple-style-span"><span style="color: black; font-family: Consolas; font-size: 10pt;">System.Net.Mail;</span></span><span style="color: black; font-size: 13.5pt;"><o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">public</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">static</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Emailer</span><o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">static</span> <span style="color: blue;">void</span> SendEmail(<span style="color: blue;">string</span> from, <span style="color: blue;">string</span> to, <span style="color: blue;">string</span> subject, <span style="color: blue;">string</span> body)<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">SmtpClient</span> smtp = <span style="color: blue;">new</span> <span style="color: #2b91af;">SmtpClient</span>(<span style="color: #a31515;">"hostname"</span>);<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">MailMessage</span> email = <span style="color: blue;">new</span> <span style="color: #2b91af;">MailMessage</span>(from, to, subject, body);<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;"> email.IsBodyHtml = <span style="color: blue;">true</span>;<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;"> smtp.Send(email);<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;"><br />
</span></span></div></div><b><u>VB.NET</u></b><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Net.Mail<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Public</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">NotInheritable</span> <span style="color: blue;">Class</span> <span style="color: #2b91af;">Emailer</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Private</span> <span style="color: blue;">Sub</span> <span style="color: blue;">New</span>()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">End</span> <span style="color: blue;">Sub</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Public</span> <span style="color: blue;">Shared</span> <span style="color: blue;">Sub</span> SendEmail(from <span style="color: blue;">As</span> <span style="color: blue;">String</span>, [to] <span style="color: blue;">As</span> <span style="color: blue;">String</span>, subject <span style="color: blue;">As</span> <span style="color: blue;">String</span>, body <span style="color: blue;">As</span> <span style="color: blue;">String</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Dim</span> smtp <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: #2b91af;">SmtpClient</span>(<span style="color: #a31515;">"hostname"</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Dim</span> email <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: #2b91af;">MailMessage</span>(<span style="color: blue;">from</span>, [to], subject, body)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> email.IsBodyHtml = <span style="color: blue;">True</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> smtp.Send(email)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">End</span> <span style="color: blue;">Sub</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">End</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Class<o:p></o:p></span></span></div><div class="MsoNormal"><br />
</div><br />
Now to send the page. Remember it can be any page and so you can do any code behind processing first that you wish. In essence we call Server.Execute which runs the page as if it were in a browser, but without opening the page in the browser for the user to see. The lines of code are simple as follows:<br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><b><u>C#</u></b></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> System.Net;</span><span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;"><o:p></o:p></span></span></div><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"> </span><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="color: black; font-family: Consolas; font-size: 9.5pt;"> System.IO:</span><span style="color: black; font-family: 'Times New Roman', serif; font-size: 12pt;"><o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><br />
</span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">protected</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">void</span> btnSendEmail_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">////*** somewhere in an aspx page - preferably a different one to the one you are emailing but doesnt have to be******</span><o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">StringWriter</span> sw = <span style="color: blue;">new</span> <span style="color: #2b91af;">StringWriter</span>();<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">HtmlTextWriter</span> htw = <span style="color: blue;">new</span> <span style="color: #2b91af;">HtmlTextWriter</span>(sw);<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;"> Server.Execute(<span style="color: #a31515;">"YourWebPage.aspx"</span>, htw); <span style="color: green;">// remember, it could be any web page</span><o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//the page has now processed and the markup is in the textwriter inner text which is the stringwriter</span><o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//I also set a status in the called aspx page and check to see all was ok before continuing but will keep it simple here</span><o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Emailer</span>.SendEmail(<span style="color: #a31515;">"from@here.com"</span>, <span style="color: #a31515;">"to@there.com"</span>, <span style="color: #a31515;">"Your aspx page"</span>, sw.ToString());<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span class="Apple-style-span" style="font-family: Consolas; font-size: x-small;"><span style="font-family: Consolas; font-size: 9.5pt;"><br />
</span></span></div></div></div><b><u>VB.NET</u></b><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><o:p> </o:p></span><span class="Apple-style-span" style="font-family: Consolas; font-size: 13px;"> </span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Net<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.IO<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Protected</span> <span style="color: blue;">Sub</span> btnSendEmail_Click(sender <span style="color: blue;">As</span> <span style="color: blue;">Object</span>, e <span style="color: blue;">As</span> <span style="color: #2b91af;">EventArgs</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">'''/*** somewhere in an aspx page - preferably a different one to the one you are emailing but doesnt have to be******</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Dim</span> sw <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: #2b91af;">StringWriter</span>()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Dim</span> htw <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: #2b91af;">HtmlTextWriter</span>(sw)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Server.Execute(<span style="color: #a31515;">"YourWebPage.aspx"</span>, htw)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">' remember, it could be any web page</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">'the page has now processed and the markup is in the textwriter inner text which is the stringwriter</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">'I also set a status in the called aspx page and check to see all was ok before continuing but will keep it simple here</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Emailer.SendEmail(<span style="color: #a31515;">"from@here.com"</span>, <span style="color: #a31515;">"to@there.com"</span>, <span style="color: #a31515;">"Your aspx page"</span>, sw.ToString())<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">End</span> <span style="color: blue;">Sub<o:p></o:p></span></span></div><div class="MsoNormal"><br />
</div><br />
You could pass parameters in the header of <span style="font-family: Consolas; font-size: 9.5pt; line-height: 115%;">Server.Execute</span> if needed or anything just as calling a normal aspx page. It you wanted to call a third party page instead then you cant use <span class="Apple-style-span" style="font-family: Consolas; font-size: 13px;">Response.Redirect.</span><br />
<br />
Remember if you want to place the code above into the page you want to email then do not put it in the page load without some form of checking (say a flag) otherwise you will go into an never-ending loop (infinite loop) and overflow error.</div>Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-52020705245471927222011-07-23T01:47:00.000-07:002011-07-23T02:37:33.299-07:00Format Source Code for Blogging Tool<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><style type="text/css">
pre.formatted-source-code
{
font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace;
color: #000000;
background-color: #eee;
font-size: 12px;
border: 1px dashed #999999;
line-height: 14px;
padding: 5px;
overflow: auto;
width: 100%;
}
p.warning
{
color: #000000;
background-color: #FFB6C1;
font-size: 12px;
border: 3px double #333333;
line-height: 14px;
padding: 5px;
overflow: auto;
width: 100%;
}
#txtRawSourceCode
{
height: 150px;
width: 575px;
}
#txtFormattedSourceCode
{
height: 200px;
width: 576px;
}
input.groovybutton
{
font-size: 15px;
font-family: Lucida Console,monospace;
font-weight: bold;
height: 50px;
background-color: #DDDDDD;
border-top-style: groove;
border-bottom-style: double;
border-left-style: ridge;
border-right-style: outset;
}
</style><br />
<script type="text/javascript">
<!--
var Color = new Array();
Color[1] = "ff";
Color[2] = "ee";
Color[3] = "dd";
Color[4] = "cc";
Color[5] = "bb";
Color[6] = "aa";
Color[7] = "99";
function fadeIn(where) {
if (where >= 1) {
document.getElementById('fade').style.backgroundColor = "#ffff" + Color[where];
if (where > 1) {
where -= 1;
setTimeout("fadeIn(" + where + ")", 200);
} else {
where -= 1;
setTimeout("fadeIn(" + where + ")", 200);
document.getElementById('fade').style.backgroundColor = "transparent";
}
}
}
function formatSourceCode() {
var strIn = document.getElementById("txtRawSourceCode").value;
var strOut = null;
// if (document.getElementById("embedstyle").checked) {
strOut = "<pre style=\"font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee;font-size: 12px;border: 1px dashed #999999;line-height: 14px;padding: 5px; overflow: auto; width: 100%\"><code>";
// hideElement("style");
// } else {
// strOut = "<pre class=\"source-code\"><code>";
// showElement("style");
// }
var strOut25 = null;
var line = 1;
var strTab;
var hasVerticalPipe = false;
var j;
if (document.getElementById("rbTab4").checked) {
strTab = " ";
} else if (document.getElementById("rbTab2").checked) {
strTab = " ";
} else {
strTab = " ";
}
for (i = 0; i < strIn.length; i++) {
var code = strIn.charCodeAt(i);
switch (code) {
case 9: // tab
strOut += strTab;
break;
case 10: // line-feed
case 13:
strOut += "\n";
line += 1;
// if (line == 26) {
// strOut25 = strOut + "[only the first 25 lines shown in this example]\n\n";
// }
j = i + 1;
if (code == 13 && j < strIn.length && strIn.charCodeAt(j) == 10) {
i++;
}
break;
case 34: // Quotation "
strOut += "</span><span style=\"background-color: transparent; color: blue; font-family: 'Courier New'; font-size: 11px; font-weight: normal;\">"";
break;
case 38:
strOut += "<span style=\"background-color: transparent; color: red; font-family: 'Courier New'; font-size: 11px; font-weight: normal;\">&";
break;
case 59: // Semi Colon
strOut += ";</span>";
break;
case 60: // Les than <
strOut += "</span><span style=\"background-color: transparent; color: maroon; font-family: 'Courier New'; font-size: 11px; font-weight: normal;\"><";
break;
case 62: // Greater than >
strOut += "></span></span><span style=\"color: black;\">";
break;
case 124: // vertical pipe (blogger modifies this)
strOut += "|";
hasVerticalPipe = true;
break;
case 32: // Blank Space
var previousCode = strIn.charCodeAt(i - 1);
switch (previousCode) {
case 34: // Quotation "
strOut += " </span><span style=\"background-color: transparent; color: red; font-family: 'Courier New'; font-size: 11px; font-weight: normal;\">";
break;
default:
strOut += " ";
break;
}
break;
case 61: // Equals Sign "="
strOut += "<span style=\"background-color: transparent; color: blue; font-family: 'Courier New'; font-size: 11px; font-weight: normal;\">=";
break;
case 47: //Slash (forward or divide)
var nextCode = strIn.charCodeAt(i + 1);
switch (nextCode) {
case 62: // Greater than >
strOut += "</span><span style=\"background-color: transparent; color: maroon; font-family: 'Courier New'; font-size: 11px; font-weight: normal;\">/";
break;
default:
strOut += "/";
break;
}
break;
default:
if (code > 32 && code <= 127) {
strOut += strIn.charAt(i);
} else {
strOut += "&#" + code + ";";
}
break;
} // switch
} // for
strOut += "\n</code></pre>";
var textoutelement = document.getElementById("txtFormattedSourceCode");
textoutelement.value = strOut;
textoutelement.focus();
textoutelement.select();
if (hasVerticalPipe) {
showElement("div-vertical-pipe-warning");
} else {
hideElement("div-vertical-pipe-warning");
}
var resultselement = document.getElementById("results");
if (strOut25 != null) {
resultselement.innerHTML = strOut25;
} else {
resultselement.innerHTML = strOut;
}
fadeIn(7);
}
function onloadEvent() {
var textinelement = document.getElementById("txtRawSourceCode");
textinelement.focus();
textinelement.select();
}
function showElement(strId) {
var ref = document.getElementById(strId);
if (ref.style) { ref = ref.style; }
ref.display = '';
}
function hideElement(strId) {
var ref = document.getElementById(strId);
if (ref.style) { ref = ref.style; }
ref.display = 'none';
}
//-->
</script><br />
<div id="style" style="display: none;">Example Stylesheet:<br />
<br />
<textarea cols="50" id="Textarea1" rows="13" wrap="off"><style type="text/css"> pre.formatted-source-code { font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; color: #000000; background-color: #eee; font-size: 12px; border: 1px dashed #999999; line-height: 14px; padding: 5px; overflow: auto; width: 100%; } </style></textarea></div><div><div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTu23_Szi9DwTvPP-_HZwoKzHiKtFXDNd60uYng2ZVfVAITixNNGqgeq1QIXaulSMfmicWE_MLekz_Pln2aKCp4fPNmRLRoJriBDcnJlCmG9O4TyIWDcGXI6gsL4Fc3tSfo3Zhh0bGmyg/s1600/Source-Code-Format-Tool-for-Blog.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjTu23_Szi9DwTvPP-_HZwoKzHiKtFXDNd60uYng2ZVfVAITixNNGqgeq1QIXaulSMfmicWE_MLekz_Pln2aKCp4fPNmRLRoJriBDcnJlCmG9O4TyIWDcGXI6gsL4Fc3tSfo3Zhh0bGmyg/s1600/Source-Code-Format-Tool-for-Blog.jpg" /></a></div><br />
<br />
So today here I am, coming up with a <strong>Source Code Formatting Tool for Blogging</strong>. Previously<br />
I had a post regarding <a href="http://www.codeshode.com/2010/06/format-my-source-code-for-blogging.html" target="_blank">How To Format My Source Code for Blogging?</a> which explained<br />
the use of <a href="http://alexgorbatchev.com/wiki/SyntaxHighlighter" target="_blank">SyntaxHighlighter</a> to format your source code for blogging. But now I feel it kinda slow down the blog to load a post. So I decided to create a tool that will provide me with Formatted HTML Code of my Source Code to post in a blog. There will be a series of such tools e.g.<br />
<br />
<ul><li>Format <strong>HTML</strong> Source Code for Blogging </li>
<li>Format <strong>XML</strong> Source Code for Blogging</li>
<li>Format <strong>ASPX</strong> Source Code for Blogging </li>
<li>Format <strong>Javascript</strong> Source Code for Blogging </li>
<li>Format <strong>SQL</strong> Source Code for Blogging </li>
<li>Format <strong>C#</strong> Source Code for Blogging </li>
<li>Format <strong>VB.NET</strong> Source Code for Blogging </li>
<li>Format <strong>CSS</strong> Source Code for Blogging </li>
</ul><br />
and <b>much more</b>. Right now, I have this tool, which will format your HTML/XML/ASPX<br />
source sode for blogging. What you need to do is Paste your Source Code in the given<br />
Text Area and your formatted source code will be provided in the other Text Area.<br />
Just copy it and paste it in your blog post or where ever you want. <br />
<br />
<a name='more'></a><br />
<br />
And thats that!<br />
<br />
<strong>P.S.</strong> Other Source Code Formatting Tool will be coming shortly or they will get embedded in current<br />
tool may. <br />
<br />
Happy Coding!<br />
Happy Shoding!<br />
<br />
</div><div style="text-align: center;"><b>::HTML-XML-ASPX Source Code Formatting Tool::</b></div><div style="text-align: center;"><br />
</div><textarea id="txtRawSourceCode" wrap="off">Paste your text here.</textarea><br />
<br />
<table><tbody>
<tr> <td><br />
<input class="groovybutton" name="groovybtn1" onclick="javascript:formatSourceCode();" title="Click Here to Format Source Code" type="button" value="Click Here to Format Source Code" /></td> <td><br />
Tab size:<br />
<input id="rbTab2" name="tabsize" type="radio" />2<input checked="true" id="rbTab4" name="tabsize" type="radio" />4<input id="rbTab8" name="tabsize" type="radio" />8<br />
<br />
</td> </tr>
</tbody></table><div class="step-instr" id="fade">Copy the HTML below to your clipboard.<br />
<br />
<textarea id="txtFormattedSourceCode" wrap="off">formatted HTML will appear in here.</textarea></div><div id="div-vertical-pipe-warning" style="display: none;"><div class="warning"><b>Vertival Pipe Character Warning:</b><br />
<br />
The text contains the vertical pipe character '|' which Blogger's editor may remove.<br />
Blogger's editor on the web has two edit tabs: "Edit HTML" and "Compose". The "Compose"<br />
tab will remove all | characters! Use the "Edit HTML" tab only.</div></div><div id="results"><pre class="formatted-source-code"><code>This is an example of what your text will look like.</code></pre><pre class="formatted-source-code"><code>• Tabs are converted to spaces.
</code><span class="Apple-style-span" style="font-family: monospace;">• Quotes and other special characters are converted to HTML.
</span><code>• Everything is enclose in HTML's 'pre' and 'code' tags.
• Style is set.
• Fixed width font.
• Shaded box.
• Dotted line border. </code></pre></div></div></div><br />
Image Courtesy: <br />
<a href="http://www.freedigitalphotos.net/images/view_photog.php?photogid=809" target="_blank">Image: Idea go / FreeDigitalPhotos.net</a></div>Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-69358499671022000202011-07-22T04:17:00.000-07:002011-07-26T06:24:49.818-07:00SQL Database Generate Password Function<div dir="ltr" style="text-align: left;" trbidi="on">Most of you might have come across need for creating a random password for the users. I prefer using passwords that are generated completely random, containing a-zA-Z0-9 and some special characters, making them tough to guess. However, thinking from the user's perspective those passwords are really hard to remember. So, if you want to leverage complexity of the passwords for making them easy to remember then here is what I have used.<br />
<br />
The key concept behind my algorithm is, a set of letters (like Basheer) forming a meaningful name is easy to remember than a set of letters (like 6ZuK3s) that makes no sense. I compiled a table with Given Names pulled from sparkleware. To generate a random password, I pick a random given name and pull out only first 6 characters from it. Then I create a random set of special characters and set of random hex digits from NewID, UUID/GUID. The random given-name part, special chars part, hex digits part all together frame a random password. This is makes password not only easy to remember, compared to completely randomized text, but also somewhat tough to predict them as well.<br />
<br />
Please note that this technique might generate passwords that can be predicted using <a href="http://en.wikipedia.org/wiki/Dictionary_attack" target="_blank">dictionary attack</a>, if considerable precautions were not taken. If your application’s password needs to highly secure then, I suggest you follow completely randomized text generation as detailed in <a href="http://codebetter.com/raymondlewallen/2005/05/17/updated-random-password-or-string-generator-in-t-sql-for-sql-server/" target="_blank">here</a>,<br />
<br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">ALTER</span><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"> <span style="color: blue;">FUNCTION</span> dbo<span style="color: grey;">.</span>udf_generate_password<span style="color: grey;">(</span>@newid <span style="color: blue;">VARCHAR</span><span style="color: grey;">(</span>50<span style="color: grey;">),</span> @rand <span style="color: blue;">REAL</span><span style="color: grey;">)</span> <span style="color: blue;">RETURNS</span> <span style="color: blue;">VARCHAR</span><span style="color: grey;">(</span>100<span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">AS<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">BEGIN<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">--****************************************************<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">--<span style="mso-spacerun: yes;"> </span>FUNCTION: DBO.UDF_GENERATE_PASSWOR<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">--<span style="mso-spacerun: yes;"> </span>AUTHOR: SHYAM K. ARJARAPU<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">--<span style="mso-spacerun: yes;"> </span>PARAMETER: @NEWID = NEWID() A UUID/GUID/NEWGUID<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">--<span style="mso-spacerun: yes;"> </span>@RAND = RAND()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">--<span style="mso-spacerun: yes;"> </span>REASON: STUPID SQL SERVER DOES NOT ALLOW NON-<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">-- <span style="mso-spacerun: yes;"> </span>DETERMINISTIC FUNCTIONS RAND(), GETDATE(), NEWID()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">--<span style="mso-spacerun: yes;"> </span>INSIDE THE FUNCTIONS.<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">--<span style="mso-spacerun: yes;"> </span>DESCRIPTION: THOUGH RANDOM PASSWORDS ARE SECURE, THEY<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">--<span style="mso-spacerun: yes;"> </span>ARE HARD TO REMEMBER. USERS CAN EASILY REMEMBER<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">--<span style="mso-spacerun: yes;"> </span>GROUP OF LETTERS FORMING A WORD. THE TABLE<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">--<span style="mso-spacerun: yes;"> </span>DBO.TB_PASSWORD_DICTIONARY CONTAINS SET OF FIRST NAMES<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">--<span style="mso-spacerun: yes;"> </span>FROM WHICH A RANDOM NAME IS SELECTED AND A SPECIAL<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">--<span style="mso-spacerun: yes;"> </span>CHARACTER WITH RANDOM STRING IS APPENDED TO MAKE THE<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">--<span style="mso-spacerun: yes;"> </span>PASSWORD NOT ONLY SECURE BUT ALSO ITS EASY TO REMEMBER<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">--<span style="mso-spacerun: yes;"> </span>USAGE:<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">-- <span style="mso-spacerun: yes;"> </span>SELECT dbo.udf_generate_password(NEWID(), RAND())<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;">--*****************************************************<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">DECLARE</span> @randPassword <span style="color: blue;">VARCHAR</span><span style="color: grey;">(</span>100<span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">DECLARE</span> @randNewID <span style="color: blue;">VARCHAR</span><span style="color: grey;">(</span>10<span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">DECLARE</span> @randFirstName <span style="color: blue;">VARCHAR</span><span style="color: grey;">(</span>6<span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">DECLARE</span> @randSpecialChar <span style="color: blue;">VARCHAR</span><span style="color: grey;">(</span>2<span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">DECLARE</span> @maxID <span style="color: blue;">INT<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">DECLARE</span> @CONST_FN_LEN <span style="color: blue;">TINYINT<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">DECLARE</span> @CONST_NID_LEN <span style="color: blue;">TINYINT<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">DECLARE</span> @CONST_SPL_LEN <span style="color: blue;">TINYINT<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">DECLARE</span> @CONST_SPL_CHARS <span style="color: blue;">VARCHAR</span><span style="color: grey;">(</span>15<span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">--DEFINE THE REQUIRED LENGTHS &amp; SPECIAL CHARS<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">SET</span> @CONST_FN_LEN <span style="color: grey;">=</span> 6<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">SET</span> @CONST_NID_LEN <span style="color: grey;">=</span> 4<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">SET</span> @CONST_SPL_LEN <span style="color: grey;">=</span> 2<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">SET</span> @CONST_SPL_CHARS <span style="color: grey;">=</span> <span style="color: red;">'@#$^*;,._!'<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">--FRAME THE RANDOM TEXT PART<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">SELECT</span> @randNewID <span style="color: grey;">=</span> <span style="color: grey;">LEFT(</span>@newid<span style="color: grey;">,</span> @CONST_NID_LEN<span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">SELECT</span> @maxID <span style="color: grey;">=</span> <span style="color: magenta;">MAX</span><span style="color: grey;">(</span>[KEY_ID]<span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">FROM</span> dbo<span style="color: grey;">.</span>tb_password_dictionary <span style="color: green;">-- Contains KEY_ID Identity(1,1), [Value] Varchar. All the given-names goes here<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">--FRAME RANDOM FIRST NAME PART<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">SELECT</span> @randFirstName <span style="color: grey;">=</span> <span style="color: grey;">LEFT(</span>[VALUE]<span style="color: grey;">,</span> @CONST_FN_LEN<span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">FROM</span> dbo<span style="color: grey;">.</span>tb_password_dictionary<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">WHERE</span> [KEY_ID] <span style="color: grey;">=</span> <span style="color: magenta;">CONVERT</span><span style="color: grey;">(</span><span style="color: blue;">INT</span><span style="color: grey;">,</span> @rand <span style="color: grey;">*</span>@maxID<span style="color: grey;">)</span> <span style="color: grey;">+</span> 1<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">SET</span> @randSpecialChar <span style="color: grey;">=</span> <span style="color: red;">''<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">--FRAME THE SPECIAL CHARTS PART<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">WHILE</span><span style="color: grey;">(</span> @CONST_SPL_LEN <span style="color: grey;">&</span>lt<span style="color: grey;">;&</span>gt<span style="color: grey;">;</span> 0<span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">BEGIN<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">SET</span> @randSpecialChar <span style="color: grey;">=</span> @randSpecialChar <span style="color: grey;">+<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: magenta;">SUBSTRING</span><span style="color: grey;">(</span>@CONST_SPL_CHARS<span style="color: grey;">,</span> <span style="color: magenta;">CONVERT</span><span style="color: grey;">(</span><span style="color: blue;">INT</span><span style="color: grey;">,</span> @rand <span style="color: grey;">*</span> <span style="color: magenta;">LEN</span><span style="color: grey;">(</span>@CONST_SPL_CHARS<span style="color: grey;">))</span> <span style="color: grey;">+</span> 1<span style="color: grey;">,</span> 1<span style="color: grey;">)<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">SET</span> @rand <span style="color: grey;">=</span> @rand <span style="color: grey;">*</span> @rand<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">SET</span> @CONST_SPL_LEN <span style="color: grey;">=</span> @CONST_SPL_LEN <span style="color: grey;">-</span> 1<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">END</span> <o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">--FRAME THE PASSWORD ALTOGETHER<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">SET</span> @randPassword <span style="color: grey;">=</span> @randFirstName <span style="color: grey;">+</span> @randSpecialChar <span style="color: grey;">+</span> @randNewID<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: "Courier New"; font-size: 10.0pt; mso-no-proof: yes;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">RETURN</span> @randPassword<o:p></o:p></span></div><div class="MsoNormal"><span style="color: blue; font-family: "Courier New"; font-size: 10.0pt; line-height: 115%; mso-no-proof: yes;">END</span><o:p></o:p></div><br />
<br />
Courtesy: <a href="http://www.arjarapu.com/" target="_blank">Shyam K. Arjarapu</a></div>Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-8320797843106775802011-07-20T23:59:00.000-07:002011-07-23T02:30:59.035-07:00Display Hierarchical Data with Menu Control in ASP.NET using C# VB.NET<div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on"><div dir="ltr" style="text-align: left;" trbidi="on">This post will show you:<br />
<br />
<ol style="text-align: left;"><li><b>How to store Hierarchical Menu Data in a Single Database Table</b></li>
<li><b>How to Display Hierarchical Data with ASP.NET Menu Control using C# and VB.NET</b>.</li>
</ol><br />
<br />
Each step is explained and illustrated so that you can quickly grasp things from this post to build your web application's menu.<br />
<br />
Before we start, lets see what we are trying to display:<br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIKFL5vC6n-tLA4F74kKUJSqfIQJxrH_clYT1AYzjBcxdGQgF7adh-sRVjkSt0hDqUlhjte904hNaJc2sNwGa7p_wlwiJrXw8ERkxomGdC74ZPdm7lpvsVdKkPgFWMKdnfnyxSlffTrAM/s1600/Database-Driven-ASP-Menu-01.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="154" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiIKFL5vC6n-tLA4F74kKUJSqfIQJxrH_clYT1AYzjBcxdGQgF7adh-sRVjkSt0hDqUlhjte904hNaJc2sNwGa7p_wlwiJrXw8ERkxomGdC74ZPdm7lpvsVdKkPgFWMKdnfnyxSlffTrAM/s320/Database-Driven-ASP-Menu-01.jpg" width="320" /></a></div><div class="separator" style="clear: both; text-align: center;"></div><a name='more'></a></div><div style="text-align: center;"><span class="Apple-style-span"><br />
</span></div><b><span class="Apple-style-span" style="color: #134f5c;">Step 1 - Create and Fill a Database Self Join Table</span></b><br />
<br />
Our menu's table will use a self-join relationship which is the simplest method of storing hierarchical data. Child rows will use ParentID to establish a relationship with the MenuID of a parent row as shown below.<br />
<br />
<div style="text-align: center;"><span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: Verdana, sans-serif; font-size: 13px;"></span></div><div class="CodeListingHeading" style="font-family: Verdana, sans-serif; font-size: 10pt; font-weight: bold; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-decoration: underline;">Figure 1 - Table Overview</div><br />
<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsusDzGcBylCp8M5kzdZc6VPkyHQDB-EscoEl29h1nFAa2nROnZ4N5tDlCELChEQDGe41bIBGRxY3XGcsbtSjJOKpfora5c4HzU8hdt9OyLKTyxihy9dfrWOTFy8153GEBX_NyYvxj9Vk/s1600/Database-Driven-ASP-Menu-02.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhsusDzGcBylCp8M5kzdZc6VPkyHQDB-EscoEl29h1nFAa2nROnZ4N5tDlCELChEQDGe41bIBGRxY3XGcsbtSjJOKpfora5c4HzU8hdt9OyLKTyxihy9dfrWOTFy8153GEBX_NyYvxj9Vk/s1600/Database-Driven-ASP-Menu-02.jpg" /></a></div></div>Let us start by creating a Table called Menu in our database.<br />
<br />
<div style="text-align: center;"><span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: Verdana, sans-serif; font-size: 13px;"></span></div><div class="CodeListingHeading" style="font-family: Verdana, sans-serif; font-size: 10pt; font-weight: bold; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-decoration: underline;">Listing 1 - Database Script</div><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">CREATE</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">TABLE</span> [dbo]<span style="color: grey;">.</span>[Menu]<span style="color: grey;">(<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: 'Courier New'; font-size: 10pt;"> [MenuID] [int] <span style="color: blue;">IDENTITY</span><span style="color: grey;">(</span>1<span style="color: grey;">,</span>1<span style="color: grey;">)</span> <span style="color: grey;">NOT</span> <span style="color: grey;">NULL,<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: 'Courier New'; font-size: 10pt;"> [Text] [varchar]<span style="color: grey;">(</span>50<span style="color: grey;">)</span> <span style="color: grey;">NULL,<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: 'Courier New'; font-size: 10pt;"> [Description] [varchar]<span style="color: grey;">(</span>255<span style="color: grey;">)</span> <span style="color: grey;">NULL,<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: 'Courier New'; font-size: 10pt;"> [ParentID] [int] <span style="color: grey;">NULL,<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">CONSTRAINT</span> [PK_Menu] <span style="color: blue;">PRIMARY</span> <span style="color: blue;">KEY</span> <span style="color: blue;">CLUSTERED</span> <o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: grey; font-family: 'Courier New'; font-size: 10pt;">(<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: 'Courier New'; font-size: 10pt;"> [MenuID] <span style="color: blue;">ASC<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: grey; font-family: 'Courier New'; font-size: 10pt;">)</span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">WITH </span><span style="color: grey; font-family: 'Courier New'; font-size: 10pt;">(</span><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">PAD_INDEX</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">=</span> <span style="color: blue;">OFF</span><span style="color: grey;">,</span> <span style="color: blue;">STATISTICS_NORECOMPUTE</span> <span style="color: grey;">=</span> <span style="color: blue;">OFF</span><span style="color: grey;">,</span> <span style="color: blue;">IGNORE_DUP_KEY</span> <span style="color: grey;">=</span> <span style="color: blue;">OFF</span><span style="color: grey;">,</span> <span style="color: blue;">ALLOW_ROW_LOCKS</span> <span style="color: grey;">=</span> <span style="color: blue;">ON</span><span style="color: grey;">,</span> <span style="color: blue;">ALLOW_PAGE_LOCKS</span> <span style="color: grey;">=</span> <span style="color: blue;">ON</span><span style="color: grey;">)</span> <span style="color: blue;">ON</span> [PRIMARY]<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: grey; font-family: 'Courier New'; font-size: 10pt;">)</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">ON</span> [PRIMARY]<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">GO<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">SET</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">ANSI_PADDING</span> <span style="color: blue;">OFF<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">GO<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">INSERT</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: blue;">INTO</span> MENU<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">Select</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: red;">'Product'</span><span style="color: grey;">,</span><span style="color: red;">'A List of Products'</span><span style="color: grey;">,</span> <span style="color: grey;">NULL<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'Applications'</span><span style="color: grey;">,</span><span style="color: red;">'Appliations'</span><span style="color: grey;">,NULL<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'Document'</span><span style="color: grey;">,</span><span style="color: red;">'Documentation'</span><span style="color: grey;">,</span> <span style="color: grey;">NULL<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'Support'</span><span style="color: grey;">,</span><span style="color: red;">'Support'</span><span style="color: grey;">,</span> <span style="color: grey;">NULL<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'Download'</span><span style="color: grey;">,</span><span style="color: red;">'Download'</span><span style="color: grey;">,</span> <span style="color: grey;">NULL<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'Background'</span><span style="color: grey;">,</span><span style="color: red;">'ProductBackground'</span><span style="color: grey;">,</span> 1<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'Details'</span><span style="color: grey;">,</span><span style="color: red;">'Product Details'</span><span style="color: grey;">,</span> 1<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'Mobile Device'</span><span style="color: grey;">,</span><span style="color: red;">'Mobile DeviceApplications'</span><span style="color: grey;">,</span> 2<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'Portal'</span><span style="color: grey;">,</span><span style="color: red;">'Portal Applications'</span><span style="color: grey;">,</span>2<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'Web Applicaitons'</span><span style="color: grey;">,</span><span style="color: red;">'WebApplications'</span><span style="color: grey;">,</span> 2<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'Demo'</span><span style="color: grey;">,</span><span style="color: red;">'Demo Applicaitons'</span><span style="color: grey;">,</span> 2<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'Performance Tests'</span><span style="color: grey;">,</span><span style="color: red;">'ApplicationPerformance Tests'</span><span style="color: grey;">,</span> 2<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'Tutorials'</span><span style="color: grey;">,</span><span style="color: red;">'TutorialDocumentation'</span><span style="color: grey;">,</span> 3<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'Programmers'</span><span style="color: grey;">,</span><span style="color: red;">'ProgrammDocumentation'</span><span style="color: grey;">,</span> 3<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'FAQ'</span><span style="color: grey;">,</span><span style="color: red;">'Frequently AskedQuestions'</span><span style="color: grey;">,</span> 4<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'Forum'</span><span style="color: grey;">,</span><span style="color: red;">'Forum'</span><span style="color: grey;">,</span> 4<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'Contact Us'</span><span style="color: grey;">,</span><span style="color: red;">'Contact Us'</span><span style="color: grey;">,</span> 4<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'InternetRestrictions'</span><span style="color: grey;">,</span><span style="color: red;">'Internet Restrictions'</span><span style="color: grey;">,</span> 6<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'Speed Solution'</span><span style="color: grey;">,</span><span style="color: red;">'Speed Solutions'</span><span style="color: grey;">,</span>6<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'Application Center Test'</span><span style="color: grey;">,</span><span style="color: red;">'Application Center Test Results'</span><span style="color: grey;">,</span> 12<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt;">UNION</span><span style="font-family: 'Courier New'; font-size: 10pt;"> <span style="color: grey;">ALL</span> <span style="color: blue;">Select</span> <span style="color: red;">'Modem Results'</span><span style="color: grey;">,</span><span style="color: red;">'Modem Results'</span><span style="color: grey;">,</span>12<o:p></o:p></span></div><div class="MsoNormal"><span style="color: blue; font-family: 'Courier New'; font-size: 10pt; line-height: 115%;">GO</span><o:p></o:p></div><br />
<br />
The table you created, displayed below, uses self-join relationships. Rows that have a MenuID between 1 through 5 do not have parents and are considered root menu nodes. Rows with MenuID of 6 and 7 are children of MenuID 1, and so on.<br />
<br />
<div style="text-align: center;"><span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: Verdana, sans-serif; font-size: 13px;"></span></div><div class="CodeListingHeading" style="font-family: Verdana, sans-serif; font-size: 10pt; font-weight: bold; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-decoration: underline;"><div style="text-align: center;">Figure 2- Parent, Child Relationships</div></div></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfJ8K531t8sPRmtqvwjjPA8ZlOkA3OrR_t6zFoVfcFhUHmFUgs605qYiw4CJxx6EeepWa6ip2G7YWab9EzjtKG9682XMip6M9443cE7w_zpGpwZEeRtuV6fhpq1Qwt14YcYTeRJmirTj4/s1600/Database-Driven-ASP-Menu-03.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgfJ8K531t8sPRmtqvwjjPA8ZlOkA3OrR_t6zFoVfcFhUHmFUgs605qYiw4CJxx6EeepWa6ip2G7YWab9EzjtKG9682XMip6M9443cE7w_zpGpwZEeRtuV6fhpq1Qwt14YcYTeRJmirTj4/s1600/Database-Driven-ASP-Menu-03.jpg" /></a></div><br />
</div><b><span class="Apple-style-span" style="color: #134f5c;"><br />
</span></b><br />
<b><span class="Apple-style-span" style="color: #134f5c;">Step 2 - Add a Web Page That Implements an asp:Menu and an XmlDataSource</span></b></div><br />
Point to be noted here, we are going to implement two Menu's</div><br />
<ul style="text-align: left;"><li>A simple menu</li>
<li>A menu with CSS styling</li>
</ul><div>Add a new WebForm to your web application. Drag and drop a Menu and an XmlDataSource from the toolbar onto the WebForm with the following properties. Listing below contains Mark up for both menu, have a look.</div><div><br />
</div><div style="text-align: center;"><span class="Apple-style-span" style="-webkit-text-decorations-in-effect: underline; font-family: Verdana, sans-serif; font-size: 13px; font-weight: bold;">Listing 2 - Menu and XmlDataSource Web Controls</span></div><div style="text-align: center;"><span class="Apple-style-span" style="-webkit-text-decorations-in-effect: underline; font-family: Verdana, sans-serif; font-size: 13px; font-weight: bold;"><br />
</span></div></div><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">link</span> <span style="color: red;">rel</span><span style="color: blue;">="stylesheet"</span> <span style="color: red;">type</span><span style="color: blue;">="text/css"</span> <span style="color: red;">href</span><span style="color: blue;">="jqueryslidemenu.css"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: darkgreen;"><!--[if lte IE 7]><o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: darkgreen; font-family: Consolas; font-size: 9.5pt;"> <style type="text/css"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: darkgreen; font-family: Consolas; font-size: 9.5pt;"> html .jqueryslidemenu{height: 1%;} /*Holly Hack for IE7 and below*/<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: darkgreen; font-family: Consolas; font-size: 9.5pt;"> </style><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: darkgreen; font-family: Consolas; font-size: 9.5pt;"> <![endif]--></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"</span> <span style="color: red;">src</span><span style="color: blue;">="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js"></</span><span style="color: maroon;">script</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"</span> <span style="color: red;">src</span><span style="color: blue;">="jqueryslidemenu.js"></</span><span style="color: maroon;">script</span><span style="color: blue;">><o:p></o:p></span></span></div><div class="MsoNormal"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Plain Menu Example:<span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Menu</span> <span style="color: red;">ID</span><span style="color: blue;">="Menu1"</span> <span style="color: red;">DataSourceID</span><span style="color: blue;">="XmlDataSource1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">BackColor</span><span style="color: blue;">="#336699"</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">DynamicHorizontalOffset</span><span style="color: blue;">="2"</span> <span style="color: red;">Font-Names</span><span style="color: blue;">="Verdana"</span> <span style="color: red;">ForeColor</span><span style="color: blue;">="#CCFFFF"</span> <span style="color: red;">StaticSubMenuIndent</span><span style="color: blue;">="10px"</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">StaticDisplayLevels</span><span style="color: blue;">="1"</span> <span style="color: red;">Orientation</span><span style="color: blue;">="Horizontal"></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">DataBindings</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">MenuItemBinding</span> <span style="color: red;">DataMember</span><span style="color: blue;">="MenuItem"</span> <span style="color: red;">NavigateUrlField</span><span style="color: blue;">="NavigateUrl"</span> <span style="color: red;">TextField</span><span style="color: blue;">="Text"</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">ToolTipField</span><span style="color: blue;">="ToolTip"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">DataBindings</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">StaticSelectedStyle</span> <span style="color: red;">BackColor</span><span style="color: blue;">="#300000"</span> <span style="color: red;">HorizontalPadding</span><span style="color: blue;">="5px"</span> <span style="color: red;">VerticalPadding</span><span style="color: blue;">="2px"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">DynamicMenuStyle</span> <span style="color: red;">BackColor</span><span style="color: blue;">="#300000"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">DynamicSelectedStyle</span> <span style="color: red;">BackColor</span><span style="color: blue;">="#FF66CC"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">DynamicMenuItemStyle</span> <span style="color: red;">HorizontalPadding</span><span style="color: blue;">="5px"</span> <span style="color: red;">VerticalPadding</span><span style="color: blue;">="2px"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">DynamicHoverStyle</span> <span style="color: red;">BackColor</span><span style="color: blue;">="#336000"</span> <span style="color: red;">Font-Bold</span><span style="color: blue;">="False"</span> <span style="color: red;">ForeColor</span><span style="color: blue;">="White"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">StaticHoverStyle</span> <span style="color: red;">BackColor</span><span style="color: blue;">="#336000"</span> <span style="color: red;">Font-Bold</span><span style="color: blue;">="False"</span> <span style="color: red;">ForeColor</span><span style="color: blue;">="White"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Menu</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Menu With CSS Example:<span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Menu</span> <span style="color: red;">ID</span><span style="color: blue;">="myslidemenu"</span> <span style="color: red;">DataSourceID</span><span style="color: blue;">="XmlDataSource1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">DynamicHorizontalOffset</span><span style="color: blue;">="2"</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">StaticSubMenuIndent</span><span style="color: blue;">="10px"</span> <span style="color: red;">StaticDisplayLevels</span><span style="color: blue;">="1"</span> <span style="color: red;">Orientation</span><span style="color: blue;">="Horizontal"</span> <span style="color: red;">CssClass</span><span style="color: blue;">="jqueryslidemenu"></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">DataBindings</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">MenuItemBinding</span> <span style="color: red;">DataMember</span><span style="color: blue;">="MenuItem"</span> <span style="color: red;">NavigateUrlField</span><span style="color: blue;">="NavigateUrl"</span> <span style="color: red;">TextField</span><span style="color: blue;">="Text"</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">ToolTipField</span><span style="color: blue;">="ToolTip"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">DataBindings</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">StaticSelectedStyle</span> <span style="color: red;">HorizontalPadding</span><span style="color: blue;">="5px"</span> <span style="color: red;">VerticalPadding</span><span style="color: blue;">="2px"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">DynamicMenuStyle</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">DynamicSelectedStyle</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">DynamicMenuItemStyle</span> <span style="color: red;">HorizontalPadding</span><span style="color: blue;">="5px"</span> <span style="color: red;">VerticalPadding</span><span style="color: blue;">="2px"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">DynamicHoverStyle</span> <span style="color: red;">Font-Bold</span><span style="color: blue;">="False"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">StaticHoverStyle</span> <span style="color: red;">Font-Bold</span><span style="color: blue;">="False"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Menu</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">XmlDataSource</span> <span style="color: red;">ID</span><span style="color: blue;">="XmlDataSource1"</span> <span style="color: red;">TransformFile</span><span style="color: blue;">="~/Menu/TransformXSLT.xslt"</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">XPath</span><span style="color: blue;">="MenuItems/MenuItem"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">XmlDataSource</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">><o:p></o:p></span></span></div><div class="MsoNormal"><br />
</div></div>At runtime, the XmlDataSource object is assigned an XML string (shown in step 3) which is then transformed by the XSLT file, TransformXSLT.xsl to another XML format (XSLT is covered in step 4). The transformed XML is then consumed by the Menu as specified by the Menu's DataSourceID property.<br />
<br />
<i>Note: We are using the XmlDataSource property, XPath, to introduce an optional way to exclude the XML root node, MenuItems. If the root node is not excluded then the menu will contain an extra level which can be controlled using the menu property StaticDisplayLevels. The MenuItems root nodes can also be excluded in XSLT.</i><br />
<br />
<br />
</div><br />
<div style="margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px;"><b><span class="Apple-style-span" style="color: #134f5c;">Step 3 - Retrieve Data and Create Nested Relationships</span></b></div></div><br />
Now it is time to retrieve and begin formatting the menu data for use by Microsoft's menu. The challenge is to establish parent child relationships and then create a hierarchical representation of the data. A DataSet object is perfect for this because it can store the structure of an entire database, including relationships, and then convert that relational data into nested XML. <br />
<br />
Add the following C# code to your Page_Load method. This code uses a DataAdapter to retrieve data from the single database table and to fill a DataSet. Once filled, a DataRelation is applied to the DataSet to establish MenuID and ParentID dependencies. Finally, a call to GetXML() retrieves a hierarchical XML representation of all relational data within the dataset.<br />
<br />
<span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: Verdana, sans-serif; font-size: 13px;"></span><br />
<div class="CodeListingHeading" style="font-family: Verdana, sans-serif; font-size: 10pt; font-weight: bold; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-align: center; text-decoration: underline;">Listing 3 - a: The C# Code</div></div><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Collections.Generic;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Linq;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web.UI;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web.UI.WebControls;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Data;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Data.SqlClient;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">namespace</span><span style="font-family: Consolas; font-size: 9.5pt;"> MenuApp<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">Menu</span> : System.Web.UI.<span style="color: #2b91af;">Page</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">protected</span> <span style="color: blue;">void</span> Page_Load(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">DataSet</span> ds = <span style="color: blue;">new</span> <span style="color: #2b91af;">DataSet</span>();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">string</span> connStr = <span style="color: #a31515;">@"Data Source=Talha-PC\SQLExpress;Initial Catalog=MenuDB;User Id=talha;Password=YourPassword;Trusted_Connection=True;"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">using</span> (<span style="color: #2b91af;">SqlConnection</span> conn = <span style="color: blue;">new</span> <span style="color: #2b91af;">SqlConnection</span>(connStr))<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">string</span> sql = <span style="color: #a31515;">"Select MenuID, Text,Description, ParentID from Menu"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">SqlDataAdapter</span> da = <span style="color: blue;">new</span> <span style="color: #2b91af;">SqlDataAdapter</span>(sql, conn);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> da.Fill(ds);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> da.Dispose();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> ds.DataSetName = <span style="color: #a31515;">"Menus"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> ds.Tables[0].TableName = <span style="color: #a31515;">"Menu"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">DataRelation</span> relation = <span style="color: blue;">new</span> <span style="color: #2b91af;">DataRelation</span>(<span style="color: #a31515;">"ParentChild"</span>,<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> ds.Tables[<span style="color: #a31515;">"Menu"</span>].Columns[<span style="color: #a31515;">"MenuID"</span>],<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> ds.Tables[<span style="color: #a31515;">"Menu"</span>].Columns[<span style="color: #a31515;">"ParentID"</span>], <span style="color: blue;">true</span>);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> relation.Nested = <span style="color: blue;">true</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> ds.Relations.Add(relation);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> XmlDataSource1.Data = ds.GetXml();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (Request.Params[<span style="color: #a31515;">"Sel"</span>] != <span style="color: blue;">null</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Page.Controls.Add(<span style="color: blue;">new</span> System.Web.UI.<span style="color: #2b91af;">LiteralControl</span>(<span style="color: #a31515;">"You selected "</span> + Request.Params[<span style="color: #a31515;">"Sel"</span>]));<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div><div class="MsoNormal"><br />
</div><div style="text-align: center;"><span class="Apple-style-span" style="-webkit-text-decorations-in-effect: underline; font-family: Verdana, sans-serif; font-size: 13px; font-weight: bold;"><u>Listing 3 - b: The VB.NET Code</u></span></div></div><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Collections.Generic<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Linq<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web.UI<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web.UI.WebControls<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Data<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Data.SqlClient<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Namespace</span><span style="font-family: Consolas; font-size: 9.5pt;"> MenuApp<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Partial</span> <span style="color: blue;">Public</span> <span style="color: blue;">Class</span> <span style="color: #2b91af;">Menu</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Inherits</span> System.Web.UI.<span style="color: #2b91af;">Page</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Protected</span> <span style="color: blue;">Sub</span> Page_Load(sender <span style="color: blue;">As</span> <span style="color: blue;">Object</span>, e <span style="color: blue;">As</span> <span style="color: #2b91af;">EventArgs</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Dim</span> ds <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: #2b91af;">DataSet</span>()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Dim</span> connStr <span style="color: blue;">As</span> <span style="color: blue;">String</span> = <span style="color: #a31515;">"Data Source=Talha-PC\SQLExpress;Initial Catalog=MenuDB;User Id=talha;Password=YourPassword;Trusted_Connection=True;"</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Using</span> conn <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: #2b91af;">SqlConnection</span>(connStr)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Dim</span> sql <span style="color: blue;">As</span> <span style="color: blue;">String</span> = <span style="color: #a31515;">"Select MenuID, Text,Description, ParentID from Menu"</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Dim</span> da <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: #2b91af;">SqlDataAdapter</span>(sql, conn)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> da.Fill(ds)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> da.Dispose()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">End</span> <span style="color: blue;">Using</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> ds.DataSetName = <span style="color: #a31515;">"Menus"</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> ds.Tables(0).TableName = <span style="color: #a31515;">"Menu"</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Dim</span> relation <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: #2b91af;">DataRelation</span>(<span style="color: #a31515;">"ParentChild"</span>, ds.Tables(<span style="color: #a31515;">"Menu"</span>).Columns(<span style="color: #a31515;">"MenuID"</span>), ds.Tables(<span style="color: #a31515;">"Menu"</span>).Columns(<span style="color: #a31515;">"ParentID"</span>), <span style="color: blue;">True</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> relation.Nested = <span style="color: blue;">True</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> ds.Relations.Add(relation)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> XmlDataSource1.Data = ds.GetXml()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">If</span> Request.Params(<span style="color: #a31515;">"Sel"</span>) <span style="color: blue;">IsNot</span> <span style="color: blue;">Nothing</span> <span style="color: blue;">Then</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Page.Controls.Add(<span style="color: blue;">New</span> System.Web.UI.<span style="color: #2b91af;">LiteralControl</span>(<span style="color: #a31515;">"You selected "</span> + Request.Params(<span style="color: #a31515;">"Sel"</span>)))<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">End</span> <span style="color: blue;">If</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">End</span> <span style="color: blue;">Sub</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">End</span> <span style="color: blue;">Class</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">End</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Namespace<o:p></o:p></span></span></div><br />
<i><br />
</i><br />
<i>Note: You will have to supply your relevant SQL Server name, Username and Password in the above database connection string, connStr.</i><br />
<i><br />
</i><br />
<span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: Verdana, sans-serif; font-size: 13px;"></span><br />
<div class="CodeListingHeading" style="font-family: Verdana, sans-serif; font-size: 10pt; font-weight: bold; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-align: center; text-decoration: underline;">Figure 3 - XML Generated By Using DataSet Relationships</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7WPUe4Tvn87FWD_1wETXgDJuohJU1feb1oUjegqoGTi2s_o8Ft3Wba6JWWz-4lXjVkT702ljK-rwhboKeul_YXKIYUmpxfJFPuToTXuVY2-RoMYX5xddpnpqiZCAJlAEPOhociHwPcc0/s1600/Database-Driven-ASP-Menu-04.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="244" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7WPUe4Tvn87FWD_1wETXgDJuohJU1feb1oUjegqoGTi2s_o8Ft3Wba6JWWz-4lXjVkT702ljK-rwhboKeul_YXKIYUmpxfJFPuToTXuVY2-RoMYX5xddpnpqiZCAJlAEPOhociHwPcc0/s320/Database-Driven-ASP-Menu-04.jpg" width="320" /></a></div><div class="separator" style="clear: both; text-align: left;"><b><span class="Apple-style-span" style="color: #134f5c;"><br />
</span></b></div><div class="separator" style="clear: both; text-align: left;"><b><span class="Apple-style-span" style="color: #134f5c;">Step 4 - Add a Web Page That Implements an asp:Menu and an XmlDataSource</span></b></div></div></div>The XML returned from ds.GetXml() now needs to be reformatted for Microsoft's Menu. XmlDataSource is perfect for this task because it can use XSLT to transform the above XML to another XML format and then provide that to Microsoft's menu.<br />
<br />
The below XSLT code does just this. It first finds the root node called Menus and applies the MenuListing template to its root children. Next, each Menu node's elements are converted to MenuItem attributes. Finally, each Menu node is checked for the existence of children. If children exist, then the MenuListing will be recursively called until all children are processed.<br />
<br />
Add an XSLT file to your project named TransformXSLT.xslt with the following code.<br />
<br />
<span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: Verdana, sans-serif; font-size: 13px;"></span><br />
<div class="CodeListingHeading" style="font-family: Verdana, sans-serif; font-size: 10pt; font-weight: bold; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-align: center; text-decoration: underline;">Listing 5 - XSLT</div></div><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><?</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">xml</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">version</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">1.0</span>"<span style="color: blue;"> </span><span style="color: red;">encoding</span><span style="color: blue;">=</span>"<span style="color: blue;">utf-8</span>"<span style="color: blue;">?></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:stylesheet</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">version</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">1.0</span>"<span style="color: blue;"> </span><span style="color: red;">xmlns:xsl</span><span style="color: blue;">=</span>"<span style="color: blue;">http://www.w3.org/1999/XSL/Transform</span>"<span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:output</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">method</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">xml</span>"<span style="color: blue;"> </span><span style="color: red;">indent</span><span style="color: blue;">=</span>"<span style="color: blue;">yes</span>"<span style="color: blue;"> </span><span style="color: red;">encoding</span><span style="color: blue;">=</span>"<span style="color: blue;">utf-8</span>"<span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><!--</span><span style="color: green; font-family: Consolas; font-size: 9.5pt;"> Replace root node name Menus with MenuItems</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: green; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>and call MenuListing for its children</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">--></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:template</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">match</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">/Menus</span>"<span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">MenuItems</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:call-template</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">MenuListing</span>"<span style="color: blue;"> /></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">MenuItems</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:template</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><!--</span><span style="color: green; font-family: Consolas; font-size: 9.5pt;"> Allow for recursive child nodeprocessing </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">--></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:template</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">MenuListing</span>"<span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:apply-templates</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">select</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Menu</span>"<span style="color: blue;"> /></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:template</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:template</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">match</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Menu</span>"<span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">MenuItem</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><!--</span><span style="color: green; font-family: Consolas; font-size: 9.5pt;"> Convert Menu child elements to MenuItem attributes </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">--></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:attribute</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Text</span>"<span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:value-of</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">select</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Text</span>"<span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:attribute</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:attribute</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">ToolTip</span>"<span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:value-of</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">select</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Description</span>"<span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:attribute</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:attribute</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">NavigateUrl</span>"<span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:text</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;">?Sel=<span style="color: blue;"></</span><span style="color: #2b91af;">xsl:text</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:value-of</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">select</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">Text</span>"<span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:attribute</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><!--</span><span style="color: green; font-family: Consolas; font-size: 9.5pt;"> Recursively call MenuListing forchild menu nodes </span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">--></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:if</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">test</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">count(Menu) >0</span>"<span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:call-template</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><span style="color: red; font-family: Consolas; font-size: 9.5pt;">name</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">=</span><span style="font-family: Consolas; font-size: 9.5pt;">"<span style="color: blue;">MenuListing</span>"<span style="color: blue;"> /></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:if</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></</span><span style="color: #a31515; font-family: Consolas; font-size: 9.5pt;">MenuItem</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span></</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:template</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: #2b91af; font-family: Consolas; font-size: 9.5pt;">xsl:stylesheet</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">><o:p></o:p></span></div><div class="MsoNormal"><br />
</div><br />
<span class="Apple-style-span" style="font-style: italic;">Note: You can interactively debug an XSLT and an XML file from the IDE's XML Menu.</span><br />
<div class="MsoNormal" style="margin-bottom: 6pt; margin-left: 0in; margin-right: 0in; margin-top: 0in;">The XmlDataSource object's transformed XML that is provided to Microsoft's Menu is shown below.</div></div><span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: Verdana, sans-serif; font-size: 13px;"></span><br />
<div class="CodeListingHeading" style="font-family: Verdana, sans-serif; font-size: 10pt; font-weight: bold; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-align: center; text-decoration: underline;">Figure 4</div></div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoTRjfOwNV9cmAPNvS4UNnI7EBt191hAyL9DieLJqEzC758e8bWJZSRU5_HAuM2TtuzmopgDB7GkuQASWkOxIGXhWTqZyafZzJKRurxR4vw8EctidBBfTfDnc_FWyBFjVeBqx2n6GVaAI/s1600/Database-Driven-ASP-Menu-05.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgoTRjfOwNV9cmAPNvS4UNnI7EBt191hAyL9DieLJqEzC758e8bWJZSRU5_HAuM2TtuzmopgDB7GkuQASWkOxIGXhWTqZyafZzJKRurxR4vw8EctidBBfTfDnc_FWyBFjVeBqx2n6GVaAI/s1600/Database-Driven-ASP-Menu-05.jpg" /></a></div></div><br />
<b><span class="Apple-style-span" style="color: #134f5c;">Step 5 - Run the Web Page</span></b></div>Run your web page to display the following menu.<br />
<div style="text-align: center;"><br />
</div><span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: Verdana, sans-serif; font-size: 13px;"></span><br />
<div class="CodeListingHeading" style="font-family: Verdana, sans-serif; font-size: 10pt; font-weight: bold; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-align: center; text-decoration: underline;">Figure 5 - The Final Output</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-acvAftugFqHXR8dwS9YhKRT_3M4CWeLI4ycFe0rCTvgN6FvqjLzcMX6RCLhqmX0Yf-6oUMHYDxcbPHjr0v8-c9rNOhw_ITmKSWsQCfug-zb4atkEgybHZS4pPNQKm3sl_46YqUZ-rWQ/s1600/Database-Driven-ASP-Menu-06.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj-acvAftugFqHXR8dwS9YhKRT_3M4CWeLI4ycFe0rCTvgN6FvqjLzcMX6RCLhqmX0Yf-6oUMHYDxcbPHjr0v8-c9rNOhw_ITmKSWsQCfug-zb4atkEgybHZS4pPNQKm3sl_46YqUZ-rWQ/s1600/Database-Driven-ASP-Menu-06.jpg" /></a></div><div class="CodeListingHeading" style="font-family: Verdana, sans-serif; font-size: 10pt; font-weight: bold; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-align: center; text-decoration: underline;"><br />
</div><div class="CodeListingHeading" style="font-family: Verdana, sans-serif; font-size: 10pt; font-weight: bold; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-align: left; text-decoration: underline;">References:</div><span class="Apple-style-span" style="-webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; font-family: Verdana, sans-serif; font-size: 13px;">Use the below references to learn how to create table relationships, format menu styles and convert XML using XSLT.</span><br />
<a href="http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconaddingrelationshipbetweentwotables.asp" target="_blank">MSDN - Adding a Relationship between Tables</a><br />
<a href="http://www.asp.net/QuickStart/aspnet/doc/ctrlref/navigation/menu.aspx" target="_blank">Menu Quick Start Tutorial</a><br />
<a href="http://www.samspublishing.com/articles/article.asp?p=131332&seqNum=1" target="_blank">Transforming XML with XSLT and ASP.NET</a><br />
<br />
<div class="CodeListingHeading" style="font-family: Verdana, sans-serif; font-size: 10pt; font-weight: bold; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-align: left; text-decoration: underline;">for CSS & JS:</div><div class="CodeListingHeading" style="font-family: Verdana, sans-serif; font-size: 10pt; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-align: left; text-decoration: underline;"><a href="http://www.dynamicdrive.com/cssexamples/media/jqueryslidemenu.css" target="_blank">http://www.dynamicdrive.com/cssexamples/media/jqueryslidemenu.css</a></div><div class="CodeListingHeading" style="font-family: Verdana, sans-serif; font-size: 10pt; margin-bottom: 0.0001pt; margin-left: 0in; margin-right: 0in; margin-top: 0in; text-align: left; text-decoration: underline;"><a href="http://www.dynamicdrive.com/cssexamples/media/jqueryslidemenu.js" target="_blank">http://www.dynamicdrive.com/cssexamples/media/jqueryslidemenu.js</a></div></div><br />
I hope its easy to understand.<br />
However, for any query, feel free to ask!<br />
<br />
Happy Coding!<br />
Happy Shoding!</div>Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-23003595339228183242011-07-18T23:05:00.000-07:002011-07-23T02:43:44.748-07:00Hit Counter for ASP.NET using C# VB.NET<div dir="ltr" style="text-align: left;" trbidi="on">This is a very simple hit counter / page counter to see how many people have visited a web page if you want to show it on a web page. This is a simple user control that is meant to be on one page (i.e., the home page). <br />
<br />
The requirements for this are a user control and read/write access to an xml file. Below is the code for the user control counter.ascx<br />
<br />
<b>Markup Code:</b><br />
<br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial; font-family: Consolas; font-size: 9.5pt;"><%</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">@</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">Control</span> <span style="color: red;">Language</span><span style="color: blue;">="C#"</span> <span style="color: red;">AutoEventWireup</span><span style="color: blue;">="true"</span> <span style="color: red;">CodeFile</span><span style="color: blue;">="counter.ascx.cs"</span> <span style="color: red;">Inherits</span><span style="color: blue;">="counter"</span> <span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial;">%></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">asp</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">:</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">Label</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">ID</span><span style="color: blue;">="lblCounter"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Label</span><span style="color: blue;">></span><o:p></o:p></span></div><br />
<a name='more'></a><br />
<br />
<b>Code for the code behind:</b><br />
<br />
<b><u>C#</u></b><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">protected</span> <span style="color: blue;">void</span> Page_Load(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">this</span>.countMe();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">DataSet</span> tmpDs = <span style="color: blue;">new</span> <span style="color: #2b91af;">DataSet</span>();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> tmpDs.ReadXml(Server.MapPath(<span style="color: #a31515;">"~/counter.xml"</span>));<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> lblCounter.Text = tmpDs.Tables[0].Rows[0][<span style="color: #a31515;">"hits"</span>].ToString();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">private</span> <span style="color: blue;">void</span> countMe()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">DataSet</span> tmpDs = <span style="color: blue;">new</span> <span style="color: #2b91af;">DataSet</span>();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> tmpDs.ReadXml(Server.MapPath(<span style="color: #a31515;">"~/counter.xml"</span>));<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">int</span> hits = <span style="color: #2b91af;">Int32</span>.Parse(tmpDs.Tables[0].Rows[0][<span style="color: #a31515;">"hits"</span>].ToString());<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> hits += 1;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> tmpDs.Tables[0].Rows[0][<span style="color: #a31515;">"hits"</span>] = hits.ToString();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> tmpDs.WriteXml(Server.MapPath(<span style="color: #a31515;">"~/counter.xml"</span>));<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal"><br />
</div><br />
<br />
<b><u>VB.NET</u></b><br />
<br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Protected</span> <span style="color: blue;">Sub</span> Page_Load(sender <span style="color: blue;">As</span> <span style="color: blue;">Object</span>, e <span style="color: blue;">As</span> <span style="color: #2b91af;">EventArgs</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Me</span>.countMe()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Dim</span> tmpDs <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: #2b91af;">DataSet</span>()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> tmpDs.ReadXml(Server.MapPath(<span style="color: #a31515;">"~/counter.xml"</span>))<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> lblCounter.Text = tmpDs.Tables(0).Rows(0)(<span style="color: #a31515;">"hits"</span>).ToString()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">End</span> <span style="color: blue;">Sub</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Private</span> <span style="color: blue;">Sub</span> countMe()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Dim</span> tmpDs <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: #2b91af;">DataSet</span>()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> tmpDs.ReadXml(Server.MapPath(<span style="color: #a31515;">"~/counter.xml"</span>))<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Dim</span> hits <span style="color: blue;">As</span> <span style="color: blue;">Integer</span> = <span style="color: #2b91af;">Int32</span>.Parse(tmpDs.Tables(0).Rows(0)(<span style="color: #a31515;">"hits"</span>).ToString())<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> hits += 1<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> tmpDs.Tables(0).Rows(0)(<span style="color: #a31515;">"hits"</span>) = hits.ToString()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> tmpDs.WriteXml(Server.MapPath(<span style="color: #a31515;">"~/counter.xml"</span>))<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">End</span> <span style="color: blue;">Sub<o:p></o:p></span></span></div><div class="MsoNormal"><br />
</div><br />
<br />
Then you need to have an xml file in the root directory to make the code work as well. The XML file will look like this:<br />
<br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;"><?</span><span style="color: maroon;">xml</span> <span style="color: red;">version</span><span style="color: blue;">="1.0"</span> <span style="color: red;">encoding</span><span style="color: blue;">="utf-8"</span> <span style="color: blue;">?></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;"><</span><span style="color: maroon;">counter</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;"><</span><span style="color: maroon;">count</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;"><</span><span style="color: maroon;">hits</span><span style="color: blue;">></span>0<span style="color: blue;"></</span><span style="color: maroon;">hits</span><span style="color: blue;">></span> <o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;"></</span><span style="color: maroon;">count</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;"></</span><span style="color: maroon;">counter</span><span style="color: blue;">></span><o:p></o:p></span></div><br />
<br />
This should do it for a simple asp.net hit counter. Not much but it's something simple and clean. I've seen others out there and didn't like them too much and plus all the free ones require some type of advertising to be associated with it. This concept is easy and you can format it however you want!<br />
<br />
Happy Coding!<br />
Happy Shoding!</div>Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-28935990528661799512011-07-16T03:45:00.000-07:002011-07-26T06:28:15.163-07:00Disable Copy HTML Using Javascript<div dir="ltr" style="text-align: left;" trbidi="on">Thinking of a way to make it more difficult for people to copy the contents of your blog? Here's a neat little JavaScript that will disable Copy and Paste.<br />
<br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;"><</span><span style="color: maroon;">script</span> <span style="color: red;">type</span><span style="color: blue;">="text/javaScript"></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">function</span> disableselect(e){<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">return</span> <span style="color: blue;">false</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">function</span> reEnable(){<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">return</span> <span style="color: blue;">true</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>document.onselectstart=<span style="color: blue;">new</span> Function (<span style="color: maroon;">"return false"</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">if</span> (window.sidebar){<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>document.onmousedown=disableselect<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>document.onclick=reEnable<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>}<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;"></</span><span style="color: maroon;">script</span><span style="color: blue;">><o:p></o:p></span></span></div><br />
<br />
Insert the code between the <head> and </head> tag.<br />
<br />
However, there is no guarantee way to prevent your contents from being stolen.The JavaScript above can be easily bypassed by an experience internet user. E.g. If the browser's JavaScript is disabled, the code will not work.</div>Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-86022296550463664652011-07-16T00:00:00.000-07:002011-07-26T06:35:55.059-07:00Convert Word Document to HTML and Display in Browser using ASP.NET<div dir="ltr" style="text-align: left;" trbidi="on">This is more a code snippet rather than an article or tutorial as it will have very less explanation as the code is simply ready to use. The following snippet allows you to <b>Convert a Microsoft Word document to HTML and display the same in browser using C# and VB.NET in ASP.NET</b>.<br />
<br />
<b>HTML Markup</b><br />
The html markup is very simple it simply has a ASP.Net FileUpload Control and a Upload button. On the click of the Upload button I am processing the uploaded word document and displaying the same in the browser.<br />
<br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">form</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">id</span><span style="color: blue;">="form1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></span><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">asp</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">:</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">FileUpload</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">ID</span><span style="color: blue;">="FileUpload1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">FileUpload</span><span style="color: blue;">></span><o:p></o:p></span></span></div><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> </span><br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">asp</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">:</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">Button</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">ID</span><span style="color: blue;">="btnUpload"</span> <span style="color: red;">OnClick</span><span style="color: blue;">="Upload"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">Text</span><span style="color: blue;">="Upload"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Button</span><span style="color: blue;">></span><o:p></o:p></span></span></div><br />
<span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">form</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">></span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><br />
<br />
Since this application only targets Microsoft Word documents. You might want to have some validations so that only word documents can be uploaded hence for that you can read the following article:<br />
<br />
<a href="http://www.codeshode.com/2011/07/validate-file-extension-for-aspnet.html">Filtering Files based on Extensions in ASP.Net FileUpload Control</a><br />
<br />
<br />
<a name='more'></a><br />
<br />
<b>Adding Reference</b><br />
In order to convert the Word Documents to HTML you will need Microsoft Word Object Library. You will need to add its reference to your project in the following way.<br />
<br />
<ul><li>On the Project menu, click Add Reference.</li>
<li>On the COM tab, locate Microsoft Word Object Library, and then click Select</li>
</ul><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9SDTZZ7Ps8XpmVtEoZs6hGM_ncyfMmzaNm2lK1fryq1r4rmz4a9D9QYvCiS-WAaMnj-6ArN9_RxfCHi1Ey_wrNBUcrEZILCYf_cAL3x2VIOLL_PA7VMqR5o3RfE59f9SaibsfOYnkDFs/s1600/Convert-Office-Word-Document-to+HTML-and-display-in-browser-ASP.Net.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj9SDTZZ7Ps8XpmVtEoZs6hGM_ncyfMmzaNm2lK1fryq1r4rmz4a9D9QYvCiS-WAaMnj-6ArN9_RxfCHi1Ey_wrNBUcrEZILCYf_cAL3x2VIOLL_PA7VMqR5o3RfE59f9SaibsfOYnkDFs/s1600/Convert-Office-Word-Document-to+HTML-and-display-in-browser-ASP.Net.png" /></a></div><br />
<b>Note:</b> Version is not important. The version of object library may vary depending on the version of Word installed on your computer.<br />
<br />
<b>Namespaces</b><br />
You will need to add the following namespaces in order to the run the application<br />
<br />
<b><u>C#</u></b><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> Microsoft.Office;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> Microsoft.Office.Interop.Word;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.IO;<o:p></o:p></span></div><br />
<br />
<b><u>VB.NET</u></b><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> Microsoft.Office<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> Microsoft.Office.Interop.Word<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.IO<o:p></o:p></span></div><br />
<br />
<b>Word to Html Conversion</b><br />
As discussed above I am converting the uploaded Word document to HTML on the upload event of the Button control.<br />
<br />
<b><u>C#</u></b><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">protected</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">void</span> Upload(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">object</span> missingType = <span style="color: #2b91af;">Type</span>.Missing;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">object</span> readOnly = <span style="color: blue;">true</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">object</span> isVisible = <span style="color: blue;">false</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">object</span> documentFormat = 8;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">string</span> randomName = <span style="color: #2b91af;">DateTime</span>.Now.Ticks.ToString();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">object</span> htmlFilePath = Server.MapPath(<span style="color: #a31515;">"~/Temp/"</span>) + randomName + <span style="color: #a31515;">".htm"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">string</span> directoryPath = Server.MapPath(<span style="color: #a31515;">"~/Temp/"</span>) + randomName + <span style="color: #a31515;">"_files"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//Upload the word document and save to Temp folder</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> FileUpload1.SaveAs(Server.MapPath(<span style="color: #a31515;">"~/Temp/"</span>) + <span style="color: #2b91af;">Path</span>.GetFileName(FileUpload1.PostedFile.FileName));<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">object</span> fileName = FileUpload1.PostedFile.FileName;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//Open the word document in background</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> ApplicationClass applicationclass = <span style="color: blue;">new</span> ApplicationClass();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> applicationclass.Documents.Open(<span style="color: blue;">ref</span> fileName,<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">ref</span> readOnly,<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> missingType,<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> missingType,<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> isVisible,<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> missingType,<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> missingType);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> applicationclass.Visible = <span style="color: blue;">false</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Document document = applicationclass.ActiveDocument;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//Save the word document as HTML file</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> document.SaveAs(<span style="color: blue;">ref</span> htmlFilePath, <span style="color: blue;">ref</span> documentFormat, <span style="color: blue;">ref</span> missingType,<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> missingType,<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> missingType,<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> missingType,<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> missingType,<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">ref</span> missingType);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//Close the word document</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> document.Close(<span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> missingType, <span style="color: blue;">ref</span> missingType);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//Delete the Uploaded Word File</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">File</span>.Delete(Server.MapPath(<span style="color: #a31515;">"~/Temp/"</span>) + <span style="color: #2b91af;">Path</span>.GetFileName(FileUpload1.PostedFile.FileName));<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//Read the Html File as Byte Array and Display it on browser</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">byte</span>[] bytes;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">using</span> (<span style="color: #2b91af;">FileStream</span> fs = <span style="color: blue;">new</span> <span style="color: #2b91af;">FileStream</span>(htmlFilePath.ToString(), <span style="color: #2b91af;">FileMode</span>.Open, <span style="color: #2b91af;">FileAccess</span>.Read))<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">BinaryReader</span> reader = <span style="color: blue;">new</span> <span style="color: #2b91af;">BinaryReader</span>(fs);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> bytes = reader.ReadBytes((<span style="color: blue;">int</span>)fs.Length);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> fs.Close();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Response.BinaryWrite(bytes);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Response.Flush();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//Delete the Html File</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">File</span>.Delete(htmlFilePath.ToString());<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">foreach</span> (<span style="color: blue;">string</span> file <span style="color: blue;">in</span> <span style="color: #2b91af;">Directory</span>.GetFiles(directoryPath))<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">File</span>.Delete(file);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">Directory</span>.Delete(directoryPath);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Response.End();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;">}</span><o:p></o:p></div><br />
<br />
<b><u>VB.NET</u></b><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Protected</span> <span style="color: blue;">Sub</span> Upload(<span style="color: blue;">ByVal</span> sender <span style="color: blue;">As</span> <span style="color: blue;">Object</span>, <span style="color: blue;">ByVal</span> e <span style="color: blue;">As</span> <span style="color: #2b91af;">EventArgs</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> missingType <span style="color: blue;">As</span> <span style="color: blue;">Object</span> = <span style="color: #2b91af;">Type</span>.Missing<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> readOnlyObject <span style="color: blue;">As</span> <span style="color: blue;">Object</span> = <span style="color: blue;">True</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> isVisible <span style="color: blue;">As</span> <span style="color: blue;">Object</span> = <span style="color: blue;">False</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> documentFormat <span style="color: blue;">As</span> <span style="color: blue;">Object</span> = 8<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> randomName <span style="color: blue;">As</span> <span style="color: blue;">String</span> = DateTime.Now.Ticks.ToString<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> htmlFilePath <span style="color: blue;">As</span> <span style="color: blue;">Object</span> = (Server.MapPath(<span style="color: #a31515;">"~/Temp/"</span>) _<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>& (randomName + <span style="color: #a31515;">".htm"</span>))<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> directoryPath <span style="color: blue;">As</span> <span style="color: blue;">String</span> = (Server.MapPath(<span style="color: #a31515;">"~/Temp/"</span>) _<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>& (randomName + <span style="color: #a31515;">"_files"</span>))<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'Upload the word document and save to Temp folder</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>FileUpload1.SaveAs((Server.MapPath(<span style="color: #a31515;">"~/Temp/"</span>) + <span style="color: #2b91af;">Path</span>.GetFileName(FileUpload1.PostedFile.FileName)))<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> fileName <span style="color: blue;">As</span> <span style="color: blue;">Object</span> = FileUpload1.PostedFile.FileName<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> applicationclass <span style="color: blue;">As</span> ApplicationClass = <span style="color: blue;">New</span> ApplicationClass<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>applicationclass.Documents.Open(fileName, readOnlyObject, missingType, missingType, missingType, missingType, missingType, missingType, missingType, missingType, isVisible, missingType, missingType, missingType, missingType, missingType)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>applicationclass.Visible = <span style="color: blue;">False</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> document <span style="color: blue;">As</span> Document = applicationclass.ActiveDocument<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'Save the word document as HTML file</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>document.SaveAs(htmlFilePath, documentFormat, missingType, missingType, missingType, missingType, missingType, missingType, missingType, missingType, missingType, missingType, missingType, missingType, missingType, missingType)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'Close the word document</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>document.Close(missingType, missingType, missingType)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'Delete the Uploaded Word File</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: #2b91af;">File</span>.Delete((Server.MapPath(<span style="color: #a31515;">"~/Temp/"</span>) + <span style="color: #2b91af;">Path</span>.GetFileName(FileUpload1.PostedFile.FileName)))<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> bytes() <span style="color: blue;">As</span> <span style="color: blue;">Byte</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> fs <span style="color: blue;">As</span> <span style="color: #2b91af;">FileStream</span> = <span style="color: blue;">New</span> <span style="color: #2b91af;">FileStream</span>(htmlFilePath.ToString, <span style="color: #2b91af;">FileMode</span>.Open, <span style="color: #2b91af;">FileAccess</span>.Read)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> reader <span style="color: blue;">As</span> <span style="color: #2b91af;">BinaryReader</span> = <span style="color: blue;">New</span> <span style="color: #2b91af;">BinaryReader</span>(fs)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>bytes = reader.ReadBytes(<span style="color: blue;">CType</span>(fs.Length, <span style="color: blue;">Integer</span>))<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>fs.Close()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>Response.BinaryWrite(bytes)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>Response.Flush()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>System.IO.<span style="color: #2b91af;">File</span>.Delete(htmlFilePath.ToString)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>Response.End()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">End</span> <span style="color: blue;">Sub</span></span><o:p></o:p></div><br />
<br />
<br />
Thats it!<br />
<br />
Happy Coding <br />
Happy Shoding</div>Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comKarachi, Pakistan24.893379 67.0280609999999824.634214 66.624313499999985 25.152544 67.431808499999974tag:blogger.com,1999:blog-6184336469392656396.post-66992230316501464922011-07-15T05:59:00.000-07:002011-07-26T06:48:26.553-07:00Send Bulk Emails using C# VB.NET in ASP.NET<div dir="ltr" style="text-align: left;" trbidi="on">I have been asked zillion times that <b>How to Send Bulk Emails using C# or VB.NET in ASP.NET</b>.<br />
<br />
Well, there are hundreds of tutorials all over the internet on sending bulk emails in ASP.NET using C# or VB.NET.<br />
<br />
However, I decided to post a basic "how to" for beginners so that they can easily understand the functionality of send bulk emails in ASP.NET.<br />
<br />
For this example I will be using Northwind Database.<br />
<br />
<b>Step 1:</b><br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-sIt09LgIqzM3ldkHmG-LqG2ySsSzNpfoZ4gjqfhaSvmDPp-12Omha_dy5Dd6f-EKADKV0hKOvozFEVl4el-6fFY0y7658A-F6cJjiBAj0sf9MBFOf4-SBCCGKPFbobfrHV7UdUHijNQ/s1600/Send-Bulk-Email-ASP.NET-CSharp-VB.NET-01.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEi-sIt09LgIqzM3ldkHmG-LqG2ySsSzNpfoZ4gjqfhaSvmDPp-12Omha_dy5Dd6f-EKADKV0hKOvozFEVl4el-6fFY0y7658A-F6cJjiBAj0sf9MBFOf4-SBCCGKPFbobfrHV7UdUHijNQ/s1600/Send-Bulk-Email-ASP.NET-CSharp-VB.NET-01.jpg" /></a></div><div class="separator" style="clear: both; text-align: center;"></div><a name='more'></a><br />
<br />
<br />
<br />
<b>ASPX Code:</b><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">form</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">id</span><span style="color: blue;">="form1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Recipient(s):<span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">TextBox</span> <span style="color: red;">ID</span><span style="color: blue;">="txtRecipient"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">Height</span><span style="color: blue;">="50px"</span> <span style="color: red;">Width</span><span style="color: blue;">="525px"</span> <o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">TextMode</span><span style="color: blue;">="MultiLine"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">TextBox</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Button</span> <span style="color: red;">ID</span><span style="color: blue;">="btnRecipientFromDB"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">onclick</span><span style="color: blue;">="btnRecipientFromDB_Click"</span> <span style="color: red;">Text</span><span style="color: blue;">="Recipient From Database"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">CheckBoxList</span> <span style="color: red;">ID</span><span style="color: blue;">="chklstRecipientsFromDB"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">Visible</span><span style="color: blue;">="False"></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">CheckBoxList</span><span style="color: blue;">><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Button</span> <span style="color: red;">ID</span><span style="color: blue;">="btnAddSelected"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">Text</span><span style="color: blue;">="Add Selected"</span> <span style="color: red;">onclick</span><span style="color: blue;">="btnAddSelected_Click"</span> <span style="color: red;">Visible</span><span style="color: blue;">="False"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Subject:<span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">TextBox</span> <span style="color: red;">ID</span><span style="color: blue;">="txtSubject"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">Height</span><span style="color: blue;">="18px"</span> <span style="color: red;">Width</span><span style="color: blue;">="522px"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">TextBox</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Email Body:<span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">TextBox</span> <span style="color: red;">ID</span><span style="color: blue;">="txtEmailBody"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">Height</span><span style="color: blue;">="290px"</span> <span style="color: red;">Width</span><span style="color: blue;">="520px"</span> <o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">TextMode</span><span style="color: blue;">="MultiLine"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">TextBox</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">br</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"><</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Button</span> <span style="color: red;">ID</span><span style="color: blue;">="btnSend"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">onclick</span><span style="color: blue;">="btnSend_Click"</span> <o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">Text</span><span style="color: blue;">="Send Email"</span> <span style="color: blue;">/></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"></</span><span style="color: maroon;">div</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">form</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">><o:p></o:p></span></div><br />
<br />
This is simple form containing 3 TextBoxes<br />
<br />
<ol><li>Recipient(s)</li>
<li>Email Subject</li>
<li>Email Body</li>
</ol><div>"<b>Add Recipients from Database</b>" button will show list of already added contacts from database as shown in image below:</div><div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6i51AJmdbyNS5Rq8qLAK3vL_OyddskSS5LunJwKk2eatKsq8U_CT37r3x_WgnAs2u4sWu6M5Vh6KM3pG2O3sm22HK64nFNZk1ozyjPtYPpmx8sqpP9BbFsgEp-eGz_91X_uaoWLy_XdA/s1600/Send-Bulk-Email-ASP.NET-CSharp-VB.NET-02.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg6i51AJmdbyNS5Rq8qLAK3vL_OyddskSS5LunJwKk2eatKsq8U_CT37r3x_WgnAs2u4sWu6M5Vh6KM3pG2O3sm22HK64nFNZk1ozyjPtYPpmx8sqpP9BbFsgEp-eGz_91X_uaoWLy_XdA/s1600/Send-Bulk-Email-ASP.NET-CSharp-VB.NET-02.jpg" /></a></div><br />
Now, user has <b>two options</b>, either they can select multiple users from list and/or they can add recipients email address manually separated by "<b>;</b>"<br />
<br />
<b><span class="Apple-style-span" style="font-size: large;">Code Behind:</span></b><br />
<b>C#:</b><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Collections.Generic;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Linq;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web.UI;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web.UI.WebControls;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Data;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Text;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">using</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Net.Mail;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">namespace</span><span style="font-family: Consolas; font-size: 9.5pt;"> TestApplication<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">public</span> <span style="color: blue;">partial</span> <span style="color: blue;">class</span> <span style="color: #2b91af;">BulkEmail</span> : System.Web.UI.<span style="color: #2b91af;">Page</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">protected</span> <span style="color: blue;">void</span> Page_Load(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (!IsPostBack)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> chklstRecipientsFromDB.Visible = <span style="color: blue;">false</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> btnAddSelected.Visible = <span style="color: blue;">false</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">protected</span> <span style="color: blue;">void</span> btnSend_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">try</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> #region</span><span style="font-family: Consolas; font-size: 9.5pt;"> Direct Email to db Recipients<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//if you want to send emails directly to recipient from database, use code below</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//DataSet dsClients = GetClientDataSet();</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//if (dsClients.Tables["Users"].Rows.Count > 0)</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//{</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">// foreach (DataRow dr in dsClients.Tables["Users"].Rows)</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">// {</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">// SendEmail(dr["Email"].ToString());</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">// }</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//}</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"> #endregion</span><span style="font-family: Consolas; font-size: 9.5pt;"><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">char</span>[] splitter = { <span style="color: #a31515;">';'</span> };<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">foreach</span> (<span style="color: blue;">string</span> emailAdd <span style="color: blue;">in</span> txtRecipient.Text.Split(splitter))<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> SendEmail(emailAdd);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">catch</span> (<span style="color: #2b91af;">Exception</span> ex)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">protected</span> <span style="color: blue;">void</span> btnRecipientFromDB_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">try</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">DataSet</span> dsClients = GetClientDataSet();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> chklstRecipientsFromDB.DataSource = dsClients.Tables[0];<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> chklstRecipientsFromDB.DataTextField = <span style="color: #a31515;">"Email"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> chklstRecipientsFromDB.DataValueField = <span style="color: #a31515;">"Email"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> chklstRecipientsFromDB.DataBind();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> chklstRecipientsFromDB.Visible = <span style="color: blue;">true</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> btnAddSelected.Visible = <span style="color: blue;">true</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> btnRecipientFromDB.Visible = <span style="color: blue;">false</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">catch</span> (<span style="color: #2b91af;">Exception</span> ex)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">finally</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> Creates and returns a DataSet using Ms Access OleDBConnection and an OleDBDataAdapter</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> A DataSet from Ms Access using an OleDBConnection and an OleDBDataAdapter</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: grey;">///</span><span style="color: green;"> </span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">private</span> System.Data.<span style="color: #2b91af;">DataSet</span> GetClientDataSet()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//retrieve the connection string from the ConnectionString Key in Web.Config</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//string connectionString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">string</span> connectionString = <span style="color: #a31515;">@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Talha\Documents\Database2.accdb;Persist Security Info=False;"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//create a new OleDB connection</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> System.Data.OleDb.<span style="color: #2b91af;">OleDbConnection</span> conn = <span style="color: blue;">new</span> System.Data.OleDb.<span style="color: #2b91af;">OleDbConnection</span>(connectionString);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//pass the Select statement and connection information to the initializxation constructor for the OleDBDataAdapter</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> System.Data.OleDb.<span style="color: #2b91af;">OleDbDataAdapter</span> myDataAdapter = <span style="color: blue;">new</span> System.Data.OleDb.<span style="color: #2b91af;">OleDbDataAdapter</span>(<span style="color: #a31515;">"SELECT Email FROM Employees"</span>, conn);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//Create a new dataset with a table : CLIENTS</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> System.Data.<span style="color: #2b91af;">DataSet</span> myDataSet = <span style="color: blue;">new</span> System.Data.<span style="color: #2b91af;">DataSet</span>(<span style="color: #a31515;">"Users"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//Fill the dataset and table with the data retrieved by the select command</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> myDataAdapter.Fill(myDataSet, <span style="color: #a31515;">"Users"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//return the new dataset created </span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">return</span> myDataSet;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">private</span> <span style="color: blue;">void</span> SendEmail(<span style="color: blue;">string</span> EmailAddress)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: green;">//Send Email Functionality here</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">MailMessage</span> mail = <span style="color: blue;">new</span> <span style="color: #2b91af;">MailMessage</span>();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> mail.To.Add(EmailAddress);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> mail.From = <span style="color: blue;">new</span> <span style="color: #2b91af;">MailAddress</span>(<span style="color: #a31515;">"admin@codeshode.com"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> mail.Subject = txtSubject.Text;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> mail.Body = txtEmailBody.Text;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> mail.IsBodyHtml = <span style="color: blue;">true</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">SmtpClient</span> smtp = <span style="color: blue;">new</span> <span style="color: #2b91af;">SmtpClient</span>();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> smtp.Host = <span style="color: #a31515;">"smtp.gmail.com"</span>; <span style="color: green;">//Or Your SMTP Server Address</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> smtp.Credentials = <span style="color: blue;">new</span> System.Net.<span style="color: #2b91af;">NetworkCredential</span>(<span style="color: #a31515;">"YourUserName@gmail.com"</span>, <span style="color: #a31515;">"YourGmailPassword"</span>);<span style="color: green;">//Or your Smtp Email ID and Password</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> smtp.EnableSsl = <span style="color: blue;">true</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> smtp.Send(mail);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">protected</span> <span style="color: blue;">void</span> btnAddSelected_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: #2b91af;">StringBuilder</span> strRecipientEmails = <span style="color: blue;">new</span> <span style="color: #2b91af;">StringBuilder</span>();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">foreach</span> (<span style="color: #2b91af;">ListItem</span> chk <span style="color: blue;">in</span> chklstRecipientsFromDB.Items)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (chk.Selected)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> strRecipientEmails.Append(chk.Value);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> strRecipientEmails.Append(<span style="color: #a31515;">";"</span>);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> txtRecipient.Text = strRecipientEmails.ToString();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> chklstRecipientsFromDB.Visible = <span style="color: blue;">false</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> btnAddSelected.Visible = <span style="color: blue;">false</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div><br />
<br />
<b>VB.NET:</b><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Collections.Generic<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Linq<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web.UI<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Web.UI.WebControls<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Data<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Text<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Imports</span><span style="font-family: Consolas; font-size: 9.5pt;"> System.Net.Mail<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">Partial</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Public</span> <span style="color: blue;">Class</span> <span style="color: #2b91af;">BulkEmail</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Inherits</span> System.Web.UI.<span style="color: #2b91af;">Page</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Protected</span> <span style="color: blue;">Sub</span> Page_Load(sender <span style="color: blue;">As</span> <span style="color: blue;">Object</span>, e <span style="color: blue;">As</span> <span style="color: #2b91af;">EventArgs</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">If</span> <span style="color: blue;">Not</span> IsPostBack <span style="color: blue;">Then</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>chklstRecipientsFromDB.Visible = <span style="color: blue;">False</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>btnAddSelected.Visible = <span style="color: blue;">False</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">End</span> <span style="color: blue;">If</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">End</span> <span style="color: blue;">Sub</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Protected</span> <span style="color: blue;">Sub</span> btnSend_Click(sender <span style="color: blue;">As</span> <span style="color: blue;">Object</span>, e <span style="color: blue;">As</span> <span style="color: #2b91af;">EventArgs</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Try</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'#Region "Direct Email to db Recipients"</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'if you want to send emails directly to recipient from database, use code below</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'DataSet dsClients = GetClientDataSet();</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'if (dsClients.Tables["Users"].Rows.Count > 0)</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'{</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'<span style="mso-spacerun: yes;"> </span>foreach (DataRow dr in dsClients.Tables["Users"].Rows)</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'<span style="mso-spacerun: yes;"> </span>{</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'<span style="mso-spacerun: yes;"> </span>SendEmail(dr["Email"].ToString());</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">' <span style="mso-spacerun: yes;"> </span>}</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'}</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'#End Region</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> splitter <span style="color: blue;">As</span> <span style="color: blue;">Char</span>() = {<span style="color: #a31515;">";"c</span>}<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">For</span> <span style="color: blue;">Each</span> emailAdd <span style="color: blue;">As</span> <span style="color: blue;">String</span> <span style="color: blue;">In</span> txtRecipient.Text.Split(splitter)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>SendEmail(emailAdd)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Next</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Catch</span> ex <span style="color: blue;">As</span> <span style="color: #2b91af;">Exception</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">End</span> <span style="color: blue;">Try</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">End</span> <span style="color: blue;">Sub</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Protected</span> <span style="color: blue;">Sub</span> btnRecipientFromDB_Click(sender <span style="color: blue;">As</span> <span style="color: blue;">Object</span>, e <span style="color: blue;">As</span> <span style="color: #2b91af;">EventArgs</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Try</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> dsClients <span style="color: blue;">As</span> <span style="color: #2b91af;">DataSet</span> = GetClientDataSet()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>chklstRecipientsFromDB.DataSource = dsClients.Tables(0)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span>chklstRecipientsFromDB.DataTextField = <span style="color: #a31515;">"Email"</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>chklstRecipientsFromDB.DataValueField = <span style="color: #a31515;">"Email"</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>chklstRecipientsFromDB.DataBind()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>chklstRecipientsFromDB.Visible = <span style="color: blue;">True</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>btnAddSelected.Visible = <span style="color: blue;">True</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Catch</span> ex <span style="color: blue;">As</span> <span style="color: #2b91af;">Exception</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Finally</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">End</span> <span style="color: blue;">Try</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">End</span> <span style="color: blue;">Sub</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">''' </span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'''<span style="mso-spacerun: yes;"> </span>Creates and returns a DataSet using Ms Access OleDBConnection and an OleDBDataAdapter</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">''' </span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">''' </span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">''' A DataSet from Ms Access using an OleDBConnection and an OleDBDataAdapter</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">''' </span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Private</span> <span style="color: blue;">Function</span> GetClientDataSet() <span style="color: blue;">As</span> System.Data.<span style="color: #2b91af;">DataSet</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'retrieve the connection string from the ConnectionString Key in Web.Config</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'string connectionString = System.Configuration.ConfigurationSettings.AppSettings["ConnectionString"];</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> connectionString <span style="color: blue;">As</span> <span style="color: blue;">String</span> = <span style="color: #a31515;">"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\Talha\Documents\Database2.accdb;Persist Security Info=False;"</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'create a new OleDB connection</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> conn <span style="color: blue;">As</span> <span style="color: blue;">New</span> System.Data.OleDb.<span style="color: #2b91af;">OleDbConnection</span>(connectionString)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'pass the Select statement and connection information to the initializxation constructor for the OleDBDataAdapter</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> myDataAdapter <span style="color: blue;">As</span> <span style="color: blue;">New</span> System.Data.OleDb.<span style="color: #2b91af;">OleDbDataAdapter</span>(<span style="color: #a31515;">"SELECT Email FROM Employees"</span>, conn)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'Create a new dataset with a table : CLIENTS</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> myDataSet <span style="color: blue;">As</span> <span style="color: blue;">New</span> System.Data.<span style="color: #2b91af;">DataSet</span>(<span style="color: #a31515;">"Users"</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'Fill the dataset and table with the data retrieved by the select command</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>myDataAdapter.Fill(myDataSet, <span style="color: #a31515;">"Users"</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'return the new dataset created </span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Return</span> myDataSet<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">End</span> <span style="color: blue;">Function</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Private</span> <span style="color: blue;">Sub</span> SendEmail(EmailAddress <span style="color: blue;">As</span> <span style="color: blue;">String</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'Send Email Functionality here</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> mail <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: #2b91af;">MailMessage</span>()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>mail.[To].Add(EmailAddress)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>mail.From = <span style="color: blue;">New</span> <span style="color: #2b91af;">MailAddress</span>(<span style="color: #a31515;">"admin@codeshode.com"</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>mail.Subject = txtSubject.Text<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>mail.Body = txtEmailBody.Text<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>mail.IsBodyHtml = <span style="color: blue;">True</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> smtp <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: #2b91af;">SmtpClient</span>()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>smtp.Host = <span style="color: #a31515;">"smtp.gmail.com"</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'Or Your SMTP Server Address</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>smtp.Credentials = <span style="color: blue;">New</span> System.Net.<span style="color: #2b91af;">NetworkCredential</span>(<span style="color: #a31515;">"YourUserName@gmail.com"</span>, <span style="color: #a31515;">"YourGmailPassword"</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: green;">'Or your Smtp Email ID and Password</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="mso-spacerun: yes;"> </span>smtp.EnableSsl = <span style="color: blue;">True</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>smtp.Send(mail)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">End</span> <span style="color: blue;">Sub</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Protected</span> <span style="color: blue;">Sub</span> btnAddSelected_Click(sender <span style="color: blue;">As</span> <span style="color: blue;">Object</span>, e <span style="color: blue;">As</span> <span style="color: #2b91af;">EventArgs</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Dim</span> strRecipientEmails <span style="color: blue;">As</span> <span style="color: blue;">New</span> <span style="color: #2b91af;">StringBuilder</span>()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">For</span> <span style="color: blue;">Each</span> chk <span style="color: blue;">As</span> <span style="color: #2b91af;">ListItem</span> <span style="color: blue;">In</span> chklstRecipientsFromDB.Items<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">If</span> chk.Selected <span style="color: blue;">Then</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>strRecipientEmails.Append(chk.Value)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>strRecipientEmails.Append(<span style="color: #a31515;">";"</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">End</span> <span style="color: blue;">If</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">Next</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>txtRecipient.Text = strRecipientEmails.ToString()<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>chklstRecipientsFromDB.Visible = <span style="color: blue;">False</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span>btnAddSelected.Visible = <span style="color: blue;">False</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"><span style="mso-spacerun: yes;"> </span><span style="color: blue;">End</span> <span style="color: blue;">Sub</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">End</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Class</span><o:p></o:p></span></div><br />
<br />
<br />
Now you may type Email Subject, Email Body and press "<b>Send Email</b>" to send bulk emails!<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZcknmyJKg1xi1dUGpK-T79MCMbsGOkv2PBvlk5sAv2nc3beEGp8KEWfLmCC3k6VttSzHwd0JGHpaI3BUBUp0KC0H5GdFAQlF8sAg5VstOSYdNWkY4UC5oLwqv7qEBIky8td_3oUIpfcI/s1600/Send-Bulk-Email-ASP.NET-CSharp-VB.NET-03.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" height="396" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjZcknmyJKg1xi1dUGpK-T79MCMbsGOkv2PBvlk5sAv2nc3beEGp8KEWfLmCC3k6VttSzHwd0JGHpaI3BUBUp0KC0H5GdFAQlF8sAg5VstOSYdNWkY4UC5oLwqv7qEBIky8td_3oUIpfcI/s400/Send-Bulk-Email-ASP.NET-CSharp-VB.NET-03.jpg" width="400" /></a></div><br />
<br />
Thats It!!<br />
<br />
Was that so difficult??<br />
<br />
I dont think so.<br />
However, for any query, feel free to contact me!<br />
<br />
Happy Coding!<br />
Happy Shoding!</div>Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.comtag:blogger.com,1999:blog-6184336469392656396.post-45797757259067725842011-07-14T03:26:00.000-07:002011-07-26T06:44:09.347-07:00Validate File Extension for ASP.NET FileUpload Control<div dir="ltr" style="text-align: left;" trbidi="on">In this article I am explaining <b>How to Create a File Extension Filter for the ASP.Net FileUpload Control</b><br />
<br />
On many occasions there’s a requirement to upload only selected types of files and reject the others<br />
<br />
In this article I will explain both Client Side and Server Side validation of files using their extensions<br />
<br />
<b>Client Side Validation:</b><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">script</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">type</span><span style="color: blue;">="text/javascript"></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> var <span style="color: blue;">val</span>idFilesTypes = ["bmp<span style="color: maroon;">", "g</span>if<span style="color: maroon;">", "p</span>ng<span style="color: maroon;">", "j</span>pg<span style="color: maroon;">", "j</span>pe<span style="color: maroon;">g", "d</span>oc<span style="color: maroon;">", "x</span>ls<span style="color: maroon;">"];<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> function<span style="color: blue;"> Validat</span>eFile() {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> var file = d<span style="color: blue;">ocu</span>ment.getElementById("<span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial;"><%</span><span style="color: blue;">=</span>FileUplo<span style="color: maroon;">ad1.ClientID<span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial;">%></span>");<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;"> </span><span style="font-family: Consolas; font-size: 9.5pt;">var label = docu<span style="color: blue;">men</span>t.getElementById("<span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial;"><%</span><span style="color: blue;">=</span>Label1.Clien<span style="color: maroon;">tID<span style="background-attachment: initial; background-clip: initial; background-color: yellow; background-image: initial; background-origin: initial;">%></span>");<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;"> var </span><span style="font-family: Consolas; font-size: 9.5pt;">path = file.valu<span style="color: blue;">e;<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> var ext = path.substring<span style="color: blue;">(pa</span>th.lastIndexOf(".") + 1, path.length).t<span style="color: maroon;">oLo</span>werCase();<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> var isValidFile = false;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"> </span> for (var i =<span style="color: blue;"> 0; i</span> < validFilesTy<span style="color: blue;">pes</span>.l<span style="color: blue;">eng</span>th; i++) {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> if (ext == validFilesTypes[i]) {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"> </span> isValidFile = true;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> break;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;"> }</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> if<span style="color: blue;"> (!is</span>ValidFile) {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> label.style.color = "re<span style="color: blue;">d"</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> label.innerHTML = "Invalid File. Please <span style="color: maroon;">uploa</span>d a File with" +<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> " extension:\n\<span style="color: maroon;">n" + validFilesTypes.join(", ");<o:p></o:p></span></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;"> </span><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: maroon;">return isValidFil</span>e;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"></</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">script</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">><o:p></o:p></span></div><br />
<br />
<br />
<a name='more'></a><br />
<br />
As you can see above I have an array validFileTypes in which I am storing the extensions of the files that I want to allow the user to upload based. Then it loops through the array and matches that with that of the file selected by the user if it does not match user is prompted to select a valid file.<br />
<br />
You can add the extensions of the File types that you want to allow to the array as shown in the animated GIF below.<br />
<div class="separator" style="clear: both; text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDeLblBO9JC7XYLHa0e3kzbHvxQWZBeHVcN24Sr1mOwKH5l0-ZXJA8rG8aCzb9-yMGn0NPdw6GifJUWVqDK1tPpBOnq4tYnlrUL2Qq5guD_iQtQypJbZavXkmmhk6gXKzh3SlXvqy8TnI/s1600/Filtering-Files-based-on-Extensions-in-ASP.Net-FileUpload-Control.gif" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhDeLblBO9JC7XYLHa0e3kzbHvxQWZBeHVcN24Sr1mOwKH5l0-ZXJA8rG8aCzb9-yMGn0NPdw6GifJUWVqDK1tPpBOnq4tYnlrUL2Qq5guD_iQtQypJbZavXkmmhk6gXKzh3SlXvqy8TnI/s1600/Filtering-Files-based-on-Extensions-in-ASP.Net-FileUpload-Control.gif" /></a></div><br />
<br />
<b>Server Side Validation:</b><br />
<br />
<b><u>C#</u></b><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><br />
</div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">protected</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">void</span> btnUpload_Click(<span style="color: blue;">object</span> sender, <span style="color: #2b91af;">EventArgs</span> e)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;">{<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">string</span>[] validFileTypes = { <span style="color: #a31515;">"bmp"</span>, <span style="color: #a31515;">"gif"</span>, <span style="color: #a31515;">"png"</span>, <span style="color: #a31515;">"jpg"</span>, <span style="color: #a31515;">"jpeg"</span>, <span style="color: #a31515;">"doc"</span>, <span style="color: #a31515;">"xls"</span> };<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">string</span> ext = System.IO.<span style="color: #2b91af;">Path</span>.GetExtension(FileUpload1.PostedFile.FileName);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">bool</span> isValidFile = <span style="color: blue;">false</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">for</span> (<span style="color: blue;">int</span> i = 0; i < validFileTypes.Length; i++)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (ext == <span style="color: #a31515;">"."</span> + validFileTypes[i])<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> isValidFile = <span style="color: blue;">true</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">break</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">if</span> (!isValidFile)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Label1.ForeColor = System.Drawing.<span style="color: #2b91af;">Color</span>.Red;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Label1.Text = <span style="color: #a31515;">"Invalid File. Please upload a File with extension "</span> +<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">string</span>.Join(<span style="color: #a31515;">","</span>, validFileTypes);<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">else</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> {<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Label1.ForeColor = System.Drawing.<span style="color: #2b91af;">Color</span>.Green;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Label1.Text = <span style="color: #a31515;">"File uploaded successfully."</span>;<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> }<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;">}<o:p></o:p></span></div><br />
<b><u><br />
</u></b><br />
<b><u>VB.NET </u></b><br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Protected</span> <span style="color: blue;">Sub</span> btnUpload_Click(<span style="color: blue;">ByVal</span> sender <span style="color: blue;">As</span> <span style="color: blue;">Object</span>, <span style="color: blue;">ByVal</span> e <span style="color: blue;">As</span> System.<span style="color: #2b91af;">EventArgs</span>)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Dim</span> validFileTypes <span style="color: blue;">As</span> <span style="color: blue;">String</span>() = {<span style="color: #a31515;">"bmp"</span>, <span style="color: #a31515;">"gif"</span>, <span style="color: #a31515;">"png"</span>, <span style="color: #a31515;">"jpg"</span>, <span style="color: #a31515;">"jpeg"</span>, <span style="color: #a31515;">"doc"</span>, <span style="color: #a31515;">"xls"</span>}<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Dim</span> ext <span style="color: blue;">As</span> <span style="color: blue;">String</span> = System.IO.<span style="color: #2b91af;">Path</span>.GetExtension(FileUpload1.PostedFile.FileName)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Dim</span> isValidFile <span style="color: blue;">As</span> <span style="color: blue;">Boolean</span> = <span style="color: blue;">False</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">For</span> i <span style="color: blue;">As</span> <span style="color: blue;">Integer</span> = 0 <span style="color: blue;">To</span> validFileTypes.Length - 1<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">If</span> ext = <span style="color: #a31515;">"."</span> & validFileTypes(i) <span style="color: blue;">Then</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> isValidFile = <span style="color: blue;">True</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Exit For</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">End</span> <span style="color: blue;">If</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Next</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">If</span> <span style="color: blue;">Not</span> isValidFile <span style="color: blue;">Then</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Label1.ForeColor = System.Drawing.<span style="color: #2b91af;">Color</span>.Red<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Label1.Text = <span style="color: #a31515;">"Invalid File. Please upload a File with extension "</span> & _<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">String</span>.Join(<span style="color: #a31515;">","</span>, validFileTypes)<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">Else</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Label1.ForeColor = System.Drawing.<span style="color: #2b91af;">Color</span>.Green<o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> Label1.Text = <span style="color: #a31515;">"File uploaded successfully."</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">End</span> <span style="color: blue;">If</span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: blue;">End</span> <span style="color: blue;">Sub<o:p></o:p></span></span></div><br />
<br />
As you will notice the Server Side File Extension validation also use the same logic as used in client side validation checking. Here also I am maintaining a string array of valid File extensions and then matching it with the extension of the File that has been uploaded. The Server Side Validation Checking ensures that the even if the JavaScript Client Side Checking fails it can be validated server side.<br />
<br />
I am calling both Server Side and Client Side Validation methods on the Click event of the Upload button as shown below. I have also used a label which will display the error or success messages. <br />
<br />
<br />
<div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">asp</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">:</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">Label</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">ID</span><span style="color: blue;">="Label1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Label</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">asp</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">:</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">FileUpload</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">ID</span><span style="color: blue;">="FileUpload1"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">FileUpload</span><span style="color: blue;">></span><o:p></o:p></span></div><div class="MsoNormal" style="line-height: normal; margin-bottom: .0001pt; margin-bottom: 0in; mso-layout-grid-align: none; text-autospace: none;"><span style="color: blue; font-family: Consolas; font-size: 9.5pt;"><</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">asp</span><span style="color: blue; font-family: Consolas; font-size: 9.5pt;">:</span><span style="color: maroon; font-family: Consolas; font-size: 9.5pt;">Button</span><span style="font-family: Consolas; font-size: 9.5pt;"> <span style="color: red;">ID</span><span style="color: blue;">="btnUpload"</span> <span style="color: red;">OnClick</span><span style="color: blue;">="Upload"</span> <span style="color: red;">runat</span><span style="color: blue;">="server"</span> <span style="color: red;">Text</span><span style="color: blue;">="Upload"</span> <span style="color: red;">OnClick</span><span style="color: blue;">="btnUpload_Click"</span> </span><span class="Apple-style-span" style="font-family: Consolas; font-size: 13px;"><span style="color: red;">OnClientClick</span><span style="color: blue;">="return ValidateFile()"></</span><span style="color: maroon;">asp</span><span style="color: blue;">:</span><span style="color: maroon;">Button</span><span style="color: blue;">></span></span></div><br />
<br />
</div>Talhahttp://www.blogger.com/profile/03999581846144746513noreply@blogger.com