tag:blogger.com,1999:blog-2597243670683654822024-03-14T02:44:50.307-07:00Sriram's ASP.NET Blogsriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.comBlogger41125tag:blogger.com,1999:blog-259724367068365482.post-72259288574756438552012-07-19T03:29:00.000-07:002012-07-19T03:29:09.388-07:00Migrate IISLog Data to SQLCE 4 Database<div dir="ltr" style="text-align: left;" trbidi="on">
I had a situation where i need to generate report from IIS Log Data. I searched for few free tools that could generate reports for me. But those reports had limited features and does not fulfill my client's requirement. So i developed a console application to move Raw IIS Log Data to SQL CE 4 database and then used Entity Framework and ASP.NET 4 Chart Controls to generate beautiful reports. <br />
<br />
using System;<br />using System.Data;<br />using System.Data.SqlServerCe;<br />using System.Collections.Generic;<br />using System.Linq;<br />using System.Text;<br />using System.Reflection;<br />using System.IO;<br />using System.Web;<br /><br />namespace ConsoleApplication1<br />{<br /> class Program<br /> {<br /> static void Main(string[] args)<br /> {<br /> System.IO.StreamReader rd = new System.IO.StreamReader("ex120710.log");<br />
// Skip first 3 lines<br /> rd.ReadLine(); rd.Peek(); rd.ReadLine(); rd.Peek(); rd.ReadLine(); rd.Peek(); rd.ReadLine(); rd.Peek();<br /> <br /> //Console.ReadLine();<br /> var directoryName = System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location);<br /> var fileName = System.IO.Path.Combine(directoryName, "IISLog.sdf");<br /><br /> /* check if exists */<br /> if (File.Exists(fileName))<br /> File.Delete(fileName);<br /><br /> string connStr = @"Data Source = " + fileName;<br /><br /> /* create Database */<br /> SqlCeEngine engine = new SqlCeEngine(connStr);<br /> engine.CreateDatabase();<br /><br /> /* create table and columns */<br /> using (SqlCeConnection conn = new SqlCeConnection(connStr))<br /> {<br /> using (SqlCeCommand cmd = new SqlCeCommand(@"CREATE TABLE IISLog (ID INT NOT NULL PRIMARY KEY,date_time datetime, s_sitename nvarchar(500), s_computername nvarchar(500), s_ip nvarchar(100), cs_method nvarchar(50), cs_uri_stem ntext, cs_uri_query ntext, s_port int, cs_username nvarchar(500), c_ip nvarchar(20), cs_version nvarchar(500), cs_User_Agent nvarchar(500), cs_Cookie nvarchar(4000), cs_Referer ntext, cs_host nvarchar(500), sc_status int, sc_substatus int, sc_win32_status int, sc_bytes int, cs_bytes int, time_taken int )", conn))<br /> //using (SqlCeCommand cmd = new SqlCeCommand(@"CREATE TABLE IISLog (date nvarchar(100), time nvarchar(100), s_sitename nvarchar(100), s_computername nvarchar(100), s_ip nvarchar(100), cs_method nvarchar(10), cs_uri_stem nvarchar(4000), cs_uri_query nvarchar(4000), s_port int, cs_username nvarchar(100), c_ip nvarchar(20), cs_version nvarchar(100), cs_User_Agent nvarchar(100), cs_Cookie nvarchar(1000), cs_Referer nvarchar(4000), cs_host nvarchar(100), sc_status nvarchar(1000), sc_substatus nvarchar(1000), sc_win32_status nvarchar(1000), sc_bytes nvarchar(1000), cs_bytes nvarchar(1000), time_taken nvarchar(1000) )", conn))<br /> {<br /> try<br /> {<br /> conn.Open();<br /> cmd.ExecuteNonQuery();<br /> }<br /> catch (Exception ex)<br /> {<br /> Console.WriteLine(ex.ToString());<br /> <br /> }<br /> finally<br /> {<br /> conn.Close();<br /> }<br /><br /> }<br /> }<br /> int i = 1;<br /> do<br /> {<br /> var l = rd.ReadLine();<br /> string[] c = l.Split(' ');<br /> DateTime date_time = Convert.ToDateTime(c[0] + " " + c[1]);<br /> string s_sitename = c[2];<br /> string s_computername = c[3];<br /> string s_ip = c[4];<br /> string cs_method = c[5];<br /> string cs_uri_stem = HttpUtility.UrlEncode(c[6]);<br /> string cs_uri_query = HttpUtility.UrlEncode(c[7]);<br /> int s_port = Convert.ToInt32(c[8]); <br /> string cs_username = c[9];<br /> string c_ip = c[10];<br /> string cs_version = c[11];<br /> string cs_User_Agent = c[12];<br /> string cs_Cookie = c[13];<br /> string cs_Referer = HttpUtility.UrlEncode(c[14]);<br /> string cs_host = c[15];<br /> int sc_status = Convert.ToInt32(c[16]);<br /> int sc_substatus = Convert.ToInt32(c[17]);<br /> int sc_win32_status = Convert.ToInt32(c[18]);<br /> int sc_bytes = Convert.ToInt32(c[19]);<br /> int cs_bytes = Convert.ToInt32(c[20]);<br /> int time_taken = Convert.ToInt32(c[21]);<br /><br /> /*int j = 1;<br /> string values = "";<br /> foreach (var r in c)<br /> {<br /> if (j == c.Count())<br /> {<br /> values += "'" + r + "'";<br /> }<br /> else<br /> {<br /> values += "'" + r + "',";<br /> }<br /> j++;<br /> }*/<br /><br /> /* create table and columns */<br /> using (SqlCeConnection conn = new SqlCeConnection(connStr))<br /> {<br /> using (SqlCeCommand cmd = new SqlCeCommand(@"insert into IISLog values ("+i.ToString() +",'" + date_time.ToString() + "','" + s_sitename + "','" + s_computername + "','" + s_ip + "','" + cs_method + "','" + cs_uri_stem + "','" + cs_uri_query + "'," + s_port.ToString() + ",'" + cs_username + "','" + c_ip + "','" + cs_version + "','" + cs_User_Agent + "','" + cs_Cookie + "','" + cs_Referer + "','" + cs_host + "'," + sc_status.ToString() + "," + sc_substatus.ToString() + "," + sc_win32_status.ToString() + "," + sc_bytes.ToString() + "," + cs_bytes.ToString() + "," + time_taken.ToString() + ")", conn))<br /> {<br /> try<br /> {<br /> conn.Open();<br /> cmd.ExecuteNonQuery();<br /> Console.WriteLine("Added Record " + i.ToString() );<br /> i++;<br /> if (i == 100)<br /> {<br /> conn.Close();<br /> break;<br /> }<br /> }<br /> catch (Exception ex)<br /> {<br /> Console.WriteLine(ex.ToString());<br /> Console.ReadLine();<br /> break;<br /> }<br /> finally<br /> {<br /> conn.Close();<br /> }<br /><br /> }<br /> }<br /> } while (rd.Peek() != -1);<br /> rd.Close();<br /> }<br /> }<br />}<br /></div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-12944601186824162272011-09-02T06:52:00.000-07:002011-09-02T06:52:01.521-07:00Load jQuery Asyc<div dir="ltr" style="text-align: left;" trbidi="on">This is a good javascript plugin that loads jQuery async and runs document.ready after jQuery is loaded and DOM initilized.<br />
<br />
http://www.yterium.net/jQl-an-asynchronous-jQuery-Loader</div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-66848751140591323432011-08-19T02:35:00.000-07:002011-08-19T02:35:24.259-07:00Oops in Javascript - Part -1<div dir="ltr" style="text-align: left;" trbidi="on">In this post i will show you how to create Classes and object instance in Javascript.<br />
<br />
<div style="color: black; overflow: auto; width: 99.5%;"><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> myclass = <span style="color: blue;">function</span><span style="color: black;"> (arg) <span style="color: black;">{</span></span></span></pre><pre style="margin: 0em;">console.log(<span style="color: maroon;">"Class initiated"</span><span style="color: black;"> );<span style="color: darkgreen;">//Check object is initiated or not</span><span style="color: black;"> </span></span></pre><pre style="margin: 0em;"><span style="color: blue;">this</span><span style="color: black;"> .arg = arg;</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;">myclass.prototype.myfunc = <span style="color: blue;">function</span><span style="color: black;"> () <span style="color: black;">{</span></span></pre><pre style="margin: 0em;">console.log(<span style="color: blue;">this</span><span style="color: black;"> .arg);</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: blue;">function</span><span style="color: black;"> TestOops() <span style="color: black;">{</span></span></pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> c = <span style="color: blue;">new</span><span style="color: black;"> myclass(<span style="color: maroon;">"obj1"</span><span style="color: black;"> ); //create first instance for myclass</span></span></span></pre><pre style="margin: 0em;">c.myfunc();<span style="color: darkgreen;">//prints obj1</span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> d = <span style="color: blue;">new</span><span style="color: black;"> myclass(<span style="color: maroon;">"obj2"</span><span style="color: black;"> );</span></span></span><span style="color: black;"><span style="color: black;"><span style="color: black;">//create second instance</span></span></span><span style="color: black;"><span style="color: black;"><span style="color: black;"> for myclass</span></span></span></pre><pre style="margin: 0em;">d.myfunc(); <span style="color: darkgreen;">//prints obj2</span><span style="color: black;"> </span></pre><pre style="margin: 0em;">c.myfunc(); <span style="color: darkgreen;">//prints obj1</span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre></div><br />
</div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-86021042580034050292011-08-19T01:56:00.001-07:002011-08-19T01:58:49.365-07:00How to create a callback function in Javascript<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div style="color: black; overflow: auto; width: 99.5%;"><pre style="margin: 0em;"><span style="color: blue;">function</span><span style="color: black;"> MyCallback(name, callbakFn) <span style="color: black;">{</span> </span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> (<span style="color: blue;">typeof</span><span style="color: black;"> (callbakFn) == 'function'<span style="color: black;"> ) <span style="color: black;">{</span></span></span></span></pre><pre style="margin: 0em;">callbakFn.call(<span style="color: blue;">this</span><span style="color: black;"> , name);</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: blue;">function</span><span style="color: black;"> TestCallback() <span style="color: black;">{</span></span></pre><pre style="margin: 0em;">MyCallback('sriram'<span style="color: black;"> , <span style="color: blue;">function</span><span style="color: black;"> (arg) <span style="color: black;">{</span></span></span></pre><pre style="margin: 0em;">alert(arg);</pre><pre style="margin: 0em;"><span style="color: black;">}</span>);</pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre></div><br />
<br />
</div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-50525534195690702762011-08-18T04:02:00.001-07:002011-08-18T04:02:41.046-07:00jQuery Detect Browser<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div style="color: black; overflow: auto; width: 99.5%;"><pre style="margin: 0em;"><span style="color: darkgreen;">// Target Firefox 2 and above </span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> ($.browser.mozilla && $.browser.version >= <span style="color: maroon;">"1.8"</span><span style="color: black;"> ) <span style="color: black;">{</span></span></span></pre><pre style="margin: 0em;"><span style="color: darkgreen;">// do something </span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: darkgreen;">// Target Safari </span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> ($.browser.safari) <span style="color: black;">{</span></span></pre><pre style="margin: 0em;"><span style="color: darkgreen;">// do something </span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: darkgreen;">// Target Chrome </span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> ($.browser.chrome) <span style="color: black;">{</span></span></pre><pre style="margin: 0em;"><span style="color: darkgreen;">// do something </span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: darkgreen;">// Target Camino </span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> ($.browser.camino) <span style="color: black;">{</span></span></pre><pre style="margin: 0em;"><span style="color: darkgreen;">// do something </span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: darkgreen;">// Target Opera </span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> ($.browser.opera) <span style="color: black;">{</span></span></pre><pre style="margin: 0em;"><span style="color: darkgreen;">// do something </span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: darkgreen;">// Target IE6 and below </span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> ($.browser.msie && $.browser.version <= 6) <span style="color: black;">{</span></span></pre><pre style="margin: 0em;"><span style="color: darkgreen;">// do something </span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: darkgreen;">// Target anything above IE6 </span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> ($.browser.msie && $.browser.version > 6) <span style="color: black;">{</span></span></pre><pre style="margin: 0em;"><span style="color: darkgreen;">// do something </span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre></div><br />
</div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-43371215141112591652011-08-18T04:01:00.000-07:002011-08-18T04:01:11.242-07:00jQuery Check element exists<div dir="ltr" style="text-align: left;" trbidi="on">if ($('#id' ).length) {<br />
// do something <br />
} <br />
<br />
<br />
</div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-86329431422041775012011-08-10T03:45:00.001-07:002011-08-10T03:46:26.680-07:00toTitleCase jQuery Plugin<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div style="color: black; overflow: auto; width: 99.5%;"><pre style="margin: 0em;">(<span style="color: blue;">function</span><span style="color: black;"> ($) <span style="color: black;">{</span></span></pre><pre style="margin: 0em;">$.fn.toTitleCase = <span style="color: blue;">function</span><span style="color: black;"> () <span style="color: black;">{</span></span></pre><pre style="margin: 0em;">$(<span style="color: blue;">this</span><span style="color: black;"> ).each(<span style="color: blue;">function</span><span style="color: black;"> () <span style="color: black;">{</span></span></span></pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> headline = $(<span style="color: blue;">this</span><span style="color: black;"> ).text();</span></span></pre><pre style="margin: 0em;">$(<span style="color: blue;">this</span><span style="color: black;">'\uc1\u8216?\uc1\u8217?"\uc1\u8220?.@:\\/\\<span style="color: black;">{</span>\\(\\[<>_]+-? *)/g, <span style="color: blue;">function</span><span style="color: black;"> (match, pl, index, title) <span style="color: black;">{</span></span></span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> (index > 0 && title.charAt(index - 2) !== <span style="color: maroon;">":"</span><span style="color: black;"> && match.search(/^(a(nd?|s|t)?|b(ut|y)|en|for|i[fn]|o[fnr]|t(he|o)|vs?\\.?|via)[ \\-]/i) > -1)</span></span></pre><pre style="margin: 0em;"><span style="color: blue;">return</span><span style="color: black;"> match.toLowerCase();</span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> (title.substring(index - 1, index +'"_<span style="color: black;">{</span>(\\[]/) > -1)</span></pre><pre style="margin: 0em;"><span style="color: blue;">return</span><span style="color: black;"> match.charAt(0) + match.charAt(1).toUpperCase() + match.substr(2);</span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> (match.substr(1).search(/[A-Z]+|&|[\\w]+[._][\\w]+/) > -1 || title.substring(index - 1, index + 1).search(/[\\])<span style="color: black;">}</span>]/) > -1)</span></pre><pre style="margin: 0em;"><span style="color: blue;">return</span><span style="color: black;"> match;</span></pre><pre style="margin: 0em;"><span style="color: blue;">return</span><span style="color: black;"> match.charAt(0).toUpperCase() + match.substr(1);</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span>));</pre><pre style="margin: 0em;"><span style="color: black;">}</span>);</pre><pre style="margin: 0em;"><span style="color: black;">}</span>;</pre><pre style="margin: 0em;"><span style="color: black;">}</span>)(jQuery);</pre><pre style="margin: 0em;"></pre></div>Source: http://plugins.jquery.com/project/titlecase</div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-2697121134522515842011-08-10T03:42:00.001-07:002011-08-10T03:43:16.124-07:00Title Case Javascript Extension<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div style="color: black; overflow: auto; width: 99.5%;"><pre style="margin: 0em;">String.prototype.toTitleCase = <span style="color: blue;">function</span><span style="color: black;"> () <span style="color: black;">{</span></span></pre><pre style="margin: 0em;"><span style="color: blue;">return</span><span style="color: black;"> <span style="color: blue;">this</span><span style="color: black;">'\uc1\u8216?\uc1\u8217?"\uc1\u8220?.@:\\/\\<span style="color: black;">{</span>\\(\\[<>_]+-? *)/g, <span style="color: blue;">function</span><span style="color: black;"> (match, p1, index, title) <span style="color: black;">{</span></span></span></span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> (index > 0 && title.charAt(index - 2) !== <span style="color: maroon;">":"</span><span style="color: black;"> &&</span></span></pre><pre style="margin: 0em;"> match.search(/^(a(nd?|s|t)?|b(ut|y)|en|for|i[fn]|o[fnr]|t(he|o)|vs?\\.?|via)[ \\-]/i) > -1)</pre><pre style="margin: 0em;"><span style="color: blue;">return</span><span style="color: black;"> match.toLowerCase();</span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> (title.substring(index - 1, index +'"_<span style="color: black;">{</span>(\\[]/) > -1)</span></pre><pre style="margin: 0em;"><span style="color: blue;">return</span><span style="color: black;"> match.charAt(0) + match.charAt(1).toUpperCase() + match.substr(2);</span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> (match.substr(1).search(/[A-Z]+|&|[\\w]+[._][\\w]+/) > -1 ||</span></pre><pre style="margin: 0em;"> title.substring(index - 1, index + 1).search(/[\\])<span style="color: black;">}</span>]/) > -1)</pre><pre style="margin: 0em;"><span style="color: blue;">return</span><span style="color: black;"> match;</span></pre><pre style="margin: 0em;"><span style="color: blue;">return</span><span style="color: black;"> match.charAt(0).toUpperCase() + match.substr(1);</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span>);</pre><pre style="margin: 0em;"><span style="color: black;">}</span>;</pre><pre style="margin: 0em;"></pre></div><br />
Source: http://individed.com/code/to-title-case/</div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-54157983093585295682011-08-08T23:15:00.000-07:002011-08-08T23:15:04.020-07:00Simple jQuery Plugin to Clear Dropdownlist options<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div style="color: black; overflow: auto; width: 99.5%;"><pre style="margin: 0em;">$.fn.clearOption = <span style="color: blue;">function</span><span style="color: black;"> () <span style="color: black;">{</span></span></pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> currentId = $(<span style="color: blue;">this</span><span style="color: black;"> ).attr(<span'< span=""><span style="color: black;"> );</span></span'<></span></span></pre><pre style="margin: 0em;">document.getElementById(currentId).options.length = 0;</pre><pre style="margin: 0em;"><span style="color: black;">}</span>;</pre><pre style="margin: 0em;"> </pre><pre style="margin: 0em;">paste this code in a external js file. clear the option element</pre><pre style="margin: 0em;">of a Dropdownlist using the folowing jQuery syntax.</pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"></pre><br />
<div style="color: black; overflow: auto; width: 99.5%;"><pre style="margin: 0em;">$(<span style="color: maroon;">"#Dropdownlist1"</span><span style="color: black;"> ).clearOption();</span></pre><pre style="margin: 0em;"></pre></div><br />
</div><br />
</div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-90387331263124309212011-07-07T06:42:00.000-07:002011-07-07T06:42:03.381-07:00Get QueryString value using javascript<div style="color: black; overflow: auto; width: 99.5%;"><pre style="margin: 0em;"><span style="color: blue;">function</span><span style="color: black;"> getAllQueryString() <span style="color: black;">{</span></span></pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> vars = [], hash;</span></pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> hashes = window.location.href.slice(window.location.href.indexOf(<span'< span=""><span style="color: black;"> ) + 1).split(<span'< span=""><span style="color: black;"> );</span></span'<></span></span'<></span></pre><pre style="margin: 0em;"><span style="color: blue;">for</span><span style="color: black;"> (<span style="color: blue;">var</span><span style="color: black;"> i = 0; i < hashes.length; i++) <span style="color: black;">{</span></span></span></pre><pre style="margin: 0em;">hash = hashes[i].split(<span'< span=""><span style="color: black;"> );</span></span'<></pre><pre style="margin: 0em;">vars.push(hash[0]);</pre><pre style="margin: 0em;">vars[hash[0]] = hash[1];</pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: blue;">return</span><span style="color: black;"> vars;</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: blue;">function</span><span style="color: black;"> getQueryString(name) <span style="color: black;">{</span></span></pre><pre style="margin: 0em;"><span style="color: blue;">return</span><span style="color: black;"> getUrlVars()[name];</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre></div><br />
<br />
Get the QueryString using the following Syntax<br />
<br />
<br />
<div style="color: black; overflow: auto; width: 99.5%;"><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> hID = getQueryString(<span'< span=""><span style="color: black;"> );</span></span'<></span></pre><pre style="margin: 0em;"></pre></div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-33489696192986176212011-07-05T06:33:00.000-07:002011-07-05T06:33:10.866-07:00How to detect popup blocker in Javascript<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div style="color: black; overflow: auto; width: 99.5%;"><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> sw1 = window.open(urlPath,"windowname" <span'< span=""><span style="color: black;"> , settings);</span></span'<></span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> (sw1)</span></pre><pre style="margin: 0em;">sw1.focus();</pre><pre style="margin: 0em;"><span style="color: blue;">else</span><span style="color: black;"> </span></pre><pre style="margin: 0em;">alert(<span'popup blocker'<="" span=""><span style="color: black;">"Popup blocker detected" );</span></span'popup></pre><pre style="margin: 0em;"></pre></div><br />
</div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-41101696942829455432011-07-01T03:41:00.001-07:002011-07-01T03:41:59.076-07:00Validate Email - No under score or @ after first @<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div style="color: black; overflow: auto; width: 99.5%;"><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: blue;"><<span style="color: maroon;">script</span><span style="color: black;"> <span style="color: red;">type<span style="color: blue;">="text/javascript"></span><span style="color: black;"> </span></span></span></span></pre><pre style="margin: 0em;"><span style="color: blue;">function</span><span style="color: black;"> fn_Email_Check(Chartocheck) <span style="color: black;">{</span></span></pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> rx = /^([A-Za-z0-9_\\-\\.])+\\@([A-Za-z0-9\\-\\.]+[^_@])+\\.([A-Za-z]<span style="color: black;">{</span>2,4<span style="color: black;">}</span>)$/;</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> (rx.test(Chartocheck) == <span style="color: blue;">false</span><span style="color: black;"> )</span></span></pre><pre style="margin: 0em;"><span style="color: blue;">return</span><span style="color: black;"> <span style="color: blue;">false</span><span style="color: black;"> ;</span></span></pre><pre style="margin: 0em;"><span style="color: blue;">else</span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: blue;">return</span><span style="color: black;"> <span style="color: blue;">true</span><span style="color: black;"> ;</span></span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: blue;"></<span style="color: maroon;">script<span style="color: blue;">></span><span style="color: black;"> </span></span></span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"></pre></div></div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-70891287012190990882011-07-01T03:38:00.001-07:002011-07-01T03:38:32.397-07:00Infinite Loop Javascript timer using Recursive function<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div style="color: black; overflow: auto; width: 99.5%;"><pre style="margin: 0em;"><span style="color: blue;"><<span style="color: maroon;">html<span style="color: blue;">></span><span style="color: black;"> </span></span></span></pre><pre style="margin: 0em;"><span style="color: blue;"><<span style="color: maroon;">head<span style="color: blue;">></span><span style="color: black;"> </span></span></span></pre><pre style="margin: 0em;"><span style="color: blue;"><<span style="color: maroon;">script</span><span style="color: black;"> <span style="color: red;">type<span style="color: blue;">="text/javascript"></span><span style="color: black;"> </span></span></span></span></pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> c = 0;</span></pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> t;</span></pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> timer_is_on = 0;</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: blue;">function</span><span style="color: black;"> timedCount() <span style="color: black;">{</span></span></pre><pre style="margin: 0em;">document.getElementById(<span'< span=""><span style="color: black;"> ).value = c;</span></span'<></pre><pre style="margin: 0em;">c = c + 1;</pre><pre style="margin: 0em;">t = setTimeout(<span style="color: maroon;">"timedCount()"</span><span style="color: black;"> , 1000);</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: blue;">function</span><span style="color: black;"> doTimer() <span style="color: black;">{</span></span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> (!timer_is_on) <span style="color: black;">{</span></span></pre><pre style="margin: 0em;">timer_is_on = 1;</pre><pre style="margin: 0em;">timedCount();</pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: blue;"></<span style="color: maroon;">script<span style="color: blue;">></span><span style="color: black;"> </span></span></span></pre><pre style="margin: 0em;"><span style="color: blue;"></<span style="color: maroon;">head<span style="color: blue;">></span><span style="color: black;"> </span></span></span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: blue;"><<span style="color: maroon;">body<span style="color: blue;">></span><span style="color: black;"> </span></span></span></pre><pre style="margin: 0em;"><span style="color: blue;"><<span style="color: maroon;">form<span style="color: blue;">></span><span style="color: black;"> </span></span></span></pre><pre style="margin: 0em;"><span style="color: blue;"><<span style="color: maroon;">input</span><span style="color: black;"> <span style="color: red;">type<span style="color: blue;">="button"</span><span style="color: black;"> <span style="color: red;">value<span style="color: blue;">="Start count!"</span><span style="color: black;"> <span style="color: red;">onclick<span style="color: blue;">="doTimer()"></span><span style="color: black;"> </span></span></span></span></span></span></span></span></pre><pre style="margin: 0em;"><span style="color: blue;"><<span style="color: maroon;">input</span><span style="color: black;"> <span style="color: red;">type<span style="color: blue;">="text"</span><span style="color: black;"> <span style="color: red;">id<span style="color: blue;">="txt"</span><span style="color: black;"> <span style="color: blue;">/></span><span style="color: black;"> </span></span></span></span></span></span></span></pre><pre style="margin: 0em;"><span style="color: blue;"></<span style="color: maroon;">form<span style="color: blue;">></span><span style="color: black;"> </span></span></span></pre><pre style="margin: 0em;"><span style="color: blue;"></<span style="color: maroon;">body<span style="color: blue;">></span><span style="color: black;"> </span></span></span></pre><pre style="margin: 0em;"><span style="color: blue;"></<span style="color: maroon;">html<span style="color: blue;">></span></span></span></pre><pre style="margin: 0em;"></pre></div><br />
</div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com1tag:blogger.com,1999:blog-259724367068365482.post-79135213959591347462011-06-28T05:49:00.000-07:002011-06-28T05:49:08.111-07:00Redirect if a page has querystring to same address with out query string.<div dir="ltr" style="text-align: left;" trbidi="on">Redirect if a page has querystring to same address with out query string.<br />
<br />
protected void Page_PreInit(object sender, EventArgs e)<br />
{<br />
if (Request.QueryString.Count > 0)<br />
{<br />
Response.Redirect(Request.Url.AbsolutePath);<br />
//Response.Write("AbsolutePath" + Request.Url.AbsolutePath);<br />
//Response.Write("<br />
AbsoluteUri" + Request.Url.AbsoluteUri);<br />
//Response.Write("<br />
PathAndQuery" + Request.Url.PathAndQuery);<br />
//Response.Write("<br />
Query" + Request.Url.Query);<br />
//Response.Write("test" + Request["test"]);<br />
}<br />
}</div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-73435434683523532982011-06-27T12:42:00.000-07:002011-06-27T13:01:54.413-07:00My First Facebook Application.<div dir="ltr" style="text-align: left;" trbidi="on">This is my first Facebook application. Developed for my Sister's Store - Just Slawars,Velachery,Chennai.<br />
<br />
Please visit the my facebook application at the below url and provide feedback.<br />
<br />
<a href="http://www.facebook.com/justsalwars.chennai?sk=app_226529810694970">http://www.facebook.com/justsalwars.chennai?sk=app_226529810694970</a><br />
<br />
<br />
</div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-44197696193046298702011-06-21T05:35:00.000-07:002011-06-21T05:35:40.319-07:00Custom macro datatype for macro properties - Umbraco<div dir="ltr" style="text-align: left;" trbidi="on">In this post i will teach you how to create a dropdown list for selecting value for Umbraco Macro Properties.Usually for Macro properties we can set only few predefined datatype while adding properties in umbraco admin. In order to have our custom datatype we need to edit Umbraco source. Open Umbraco source code in Visual Studio. Add a new class to <b style="color: blue;">umbraco.macroRenderings </b><span style="color: blue;"><span style="color: black;">project with the following code.</span></span><br />
<br />
<span style="color: blue;"><span style="color: black;"> </span></span><b style="color: blue;"><br />
</b><br />
<br />
<div style="color: black; overflow: auto; width: 99.5%;"><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Collections.Generic;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Linq;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Text;</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: blue;">namespace</span><span style="color: black;"> umbraco.macroRenderings</span></pre><pre style="margin: 0em;"><span style="color: black;">{</span></pre><pre style="margin: 0em;"><span style="color: blue;">class</span><span style="color: black;"> <span style="color: #2b91af;">HotelsDropdown</span><span style="color: black;"> : System.Web.UI.WebControls.<span style="color: #2b91af;">DropDownList</span><span style="color: black;"> , umbraco.interfaces.<span style="color: #2b91af;">IMacroGuiRendering</span><span style="color: black;"> </span></span></span></span></pre><pre style="margin: 0em;"><span style="color: black;">{</span></pre><pre style="margin: 0em;"><span style="color: blue;">string</span><span style="color: black;"> _value = <span style="color: blue;">string</span><span style="color: black;"> .Empty;</span></span></pre><pre style="margin: 0em;"><span style="color: blue;">public</span><span style="color: black;"> <span style="color: blue;">string</span><span style="color: black;"> Value</span></span></pre><pre style="margin: 0em;"><span style="color: black;">{</span></pre><pre style="margin: 0em;"><span style="color: blue;">get</span><span style="color: black;"> <span style="color: black;">{</span></span></pre><pre style="margin: 0em;"><span style="color: blue;">string</span><span style="color: black;"> retVal = <span style="color: blue;">string</span><span style="color: black;"> .Empty;</span></span></pre><pre style="margin: 0em;"><span style="color: blue;">foreach</span><span style="color: black;"> (System.Web.UI.WebControls.<span style="color: #2b91af;">ListItem</span><span style="color: black;"> i <span style="color: blue;">in</span><span style="color: black;"> <span style="color: blue;">base</span><span style="color: black;"> .Items)</span></span></span></span></pre><pre style="margin: 0em;"><span style="color: black;">{</span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> (i.Selected == <span style="color: blue;">true</span><span style="color: black;"> )</span></span></pre><pre style="margin: 0em;"><span style="color: black;">{</span></pre><pre style="margin: 0em;">retVal = i.Value;</pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: blue;">return</span><span style="color: black;"> retVal;</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: blue;">set</span><span style="color: black;"> <span style="color: black;">{</span> _value = <span style="color: blue;">value</span><span style="color: black;"> ; <span style="color: black;">}</span></span></span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: blue;">public</span><span style="color: black;"> <span style="color: blue;">bool</span><span style="color: black;"> ShowCaption</span></span></pre><pre style="margin: 0em;"><span style="color: black;">{</span></pre><pre style="margin: 0em;"><span style="color: blue;">get</span><span style="color: black;"> <span style="color: black;">{</span> <span style="color: blue;">return</span><span style="color: black;"> <span style="color: blue;">true</span><span style="color: black;"> ; <span style="color: black;">}</span></span></span></span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: blue;">protected</span><span style="color: black;"> <span style="color: blue;">override</span><span style="color: black;"> <span style="color: blue;">void</span><span style="color: black;"> OnInit(<span style="color: #2b91af;">EventArgs</span><span style="color: black;"> e)</span></span></span></span></pre><pre style="margin: 0em;"><span style="color: black;">{</span></pre><pre style="margin: 0em;"><span style="color: blue;">base</span><span style="color: black;"> .OnInit(e);</span></pre><pre style="margin: 0em;"><span style="color: blue;">for</span><span style="color: black;"> (<span style="color: blue;">int</span><span style="color: black;"> i = 0; i < 5; i++)</span></span></pre><pre style="margin: 0em;"><span style="color: black;">{</span></pre><pre style="margin: 0em;">System.Web.UI.WebControls.<span style="color: #2b91af;">ListItem</span><span style="color: black;"> li = <span style="color: blue;">new</span><span style="color: black;"> System.Web.UI.WebControls.<span style="color: #2b91af;">ListItem</span><span style="color: black;"> (<span style="color: #a31515;">"test"</span><span style="color: black;"> + i.ToString());</span></span></span></span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> (_value == <span style="color: #a31515;">"test"</span><span style="color: black;"> + i.ToString())</span></span></pre><pre style="margin: 0em;">li.Selected = <span style="color: blue;">true</span><span style="color: black;"> ;</span></pre><pre style="margin: 0em;"><span style="color: blue;">this</span><span style="color: black;"> .Items.Add(li);</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"></pre></div><br />
compile and copy .dll to umbraco bin.<br />
<br />
add macro class info to umbraco "cmsMacroPropertyType" table:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTUUYl5_EGwK5LDtdZGoDIJKpUOQpd2SeBTI_18S6hYLEOgNw0YNnRf_CByX1nSHwRk-nLyua4ZLaA-exviu_7wxxminAFxxpJ_zkx3AyZj4uwGtZ26HqG7e9PtK6KyJPByShBXOvqK63E/s1600/macro.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="237" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhTUUYl5_EGwK5LDtdZGoDIJKpUOQpd2SeBTI_18S6hYLEOgNw0YNnRf_CByX1nSHwRk-nLyua4ZLaA-exviu_7wxxminAFxxpJ_zkx3AyZj4uwGtZ26HqG7e9PtK6KyJPByShBXOvqK63E/s400/macro.JPG" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Click image to enlarge</td></tr>
</tbody></table><br />
<br />
add new object type to your macro:<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBfRCW0EUiIjHu4qO51NVe4F7VFIdprWdOiqafM3M861czR_8AZrRptIHzNdNnXae8dyI3E72Hu0keuCsdSQBztwfxIG_SVjL9XTwZ7TkNRIDQT3I6kZZy_mqd4uZi1zP_Me42V_fvNi73/s1600/macro.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="218" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhBfRCW0EUiIjHu4qO51NVe4F7VFIdprWdOiqafM3M861czR_8AZrRptIHzNdNnXae8dyI3E72Hu0keuCsdSQBztwfxIG_SVjL9XTwZ7TkNRIDQT3I6kZZy_mqd4uZi1zP_Me42V_fvNi73/s400/macro.JPG" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Click image to enlarge</td></tr>
</tbody></table><br />
add/embed macro in page or template and set macro property values using the our Dropdown:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFa5SMdMeJwtz8Kkrn01BgVyclOLZn3fdyFw0rEW1De5Z_kfufCaAo-IeX6NsFtZ_6hZY7AhbNd0imxXNMnWLMYnoQGsE72iEMTBRnxjdj3ebDrTmbdd7NkWUa_s9Ssy5Wccpx1miSvf5v/s1600/macro.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="224" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiFa5SMdMeJwtz8Kkrn01BgVyclOLZn3fdyFw0rEW1De5Z_kfufCaAo-IeX6NsFtZ_6hZY7AhbNd0imxXNMnWLMYnoQGsE72iEMTBRnxjdj3ebDrTmbdd7NkWUa_s9Ssy5Wccpx1miSvf5v/s400/macro.JPG" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Click image to enlarge</td></tr>
</tbody></table><br />
<br />
Output in editor:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglYAPOmEXFFWUdfnpGJgNCrBh_vwZ7YXBjmAcBlWiwe5DHzrwnHZGZJJTnkDZ8McJGSWRAJiiPBsdeLFjYdQzD0wW6vFaRLttlXAzBHts0bMa_jN0GhwJbekpNFY_xwxECk30Jb3Grhcr2/s1600/macro.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="361" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEglYAPOmEXFFWUdfnpGJgNCrBh_vwZ7YXBjmAcBlWiwe5DHzrwnHZGZJJTnkDZ8McJGSWRAJiiPBsdeLFjYdQzD0wW6vFaRLttlXAzBHts0bMa_jN0GhwJbekpNFY_xwxECk30Jb3Grhcr2/s400/macro.JPG" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Click image to enlarge</td></tr>
</tbody></table><br />
Output in browser:<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZmdyVNemPW4Naif6fK5VP5jx9olJhyRwDwQpYzv0-PB-wMYRqU425AYAeuLkQbcIxn46YyRoOsw47DfzoN3RMWFJZlcwo_NWHucgiI-j8mdBRUG2NeNd5ZASzkMQyhaDNsrF6I692Wi4R/s1600/macro.JPG" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" height="223" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgZmdyVNemPW4Naif6fK5VP5jx9olJhyRwDwQpYzv0-PB-wMYRqU425AYAeuLkQbcIxn46YyRoOsw47DfzoN3RMWFJZlcwo_NWHucgiI-j8mdBRUG2NeNd5ZASzkMQyhaDNsrF6I692Wi4R/s400/macro.JPG" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Click image to enlarge</td></tr>
</tbody></table><br />
<br />
</div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-77288763871477454342011-06-15T05:00:00.001-07:002011-06-15T05:00:02.282-07:00Validate Email - Javascript<!-- Start block. Created with Code4Blog for Microsoft Visual Studio 2010. Copyright (c)2010 Vitaly Zayko http://zayko.net --><br />
<div style="color:black;overflow:auto;width:99.5%;"><pre style="margin:0em;"><span style="color:#0000ff"><<span style="color:#800000">script</span><span style="color:#000000"> <span style="color:#ff0000">type<span style="color:#0000ff">="text/javascript"></span><span style="color:#000000"> </pre><pre style="margin:0em;"><span style="color:#006400">//Function to validate Email</span><span style="color:#000000"> </pre><pre style="margin:0em;"><span style="color:#0000ff">function</span><span style="color:#000000"> IsValidEmail(email) <span style="color:#000000">{</span></pre><pre style="margin:0em;"><span style="color:#006400">//var exclude=/[^@\\-\\.\\w]|^[_@\\.\\-]|[\\._\\-]<span style="color:#000000">{</span>2<span style="color:#000000">}</span>|[@\\.]<span style="color:#000000">{</span>2<span style="color:#000000">}</span>|(@)[^@]*\\1/;</span><span style="color:#000000"> </pre><pre style="margin:0em;"><span style="color:#0000ff">var</span><span style="color:#000000"> exclude = /[^@\\-\\.\\w]|^[_@\\.\\]|[\\._\\-]<span style="color:#000000">{</span>2<span style="color:#000000">}</span>|[@\\.]<span style="color:#000000">{</span>2<span style="color:#000000">}</span>|(@)[^@]*\\1/;</pre><pre style="margin:0em;"><span style="color:#0000ff">var</span><span style="color:#000000"> checkend = /\\.[a-zA-Z]<span style="color:#000000">{</span>2,3<span style="color:#000000">}</span>$/;</pre><pre style="margin:0em;"></pre><pre style="margin:0em;"><span style="color:#0000ff">if</span><span style="color:#000000"> ((email.search(exclude) != -1) || (email.search(checkend) == -1)) <span style="color:#000000">{</span></pre><pre style="margin:0em;"><span style="color:#0000ff">return</span><span style="color:#000000"> <span style="color:#0000ff">false</span><span style="color:#000000"> ;</pre><pre style="margin:0em;"><span style="color:#000000">}</span></pre><pre style="margin:0em;">atPos = email.indexOf(<span style="color:#800000">"@"</span><span style="color:#000000"> , 0);</pre><pre style="margin:0em;">pPos1 = email.indexOf(<span style="color:#800000">"."</span><span style="color:#000000"> , 0);</pre><pre style="margin:0em;">periodPos = email.indexOf(<span style="color:#800000">"."</span><span style="color:#000000"> , atPos);</pre><pre style="margin:0em;">pos1 = pPos1;</pre><pre style="margin:0em;">pos2 = 0;</pre><pre style="margin:0em;"><span style="color:#0000ff">while</span><span style="color:#000000"> (pos2 > -1) <span style="color:#000000">{</span></pre><pre style="margin:0em;">pos2 = email.indexOf(<span style="color:#800000">"."</span><span style="color:#000000"> , pos1 + 1);</pre><pre style="margin:0em;"><span style="color:#0000ff">if</span><span style="color:#000000"> (pos2 == pos1 + 1) <span style="color:#000000">{</span></pre><pre style="margin:0em;"><span style="color:#0000ff">return</span><span style="color:#000000"> <span style="color:#0000ff">false</span><span style="color:#000000"> ;</pre><pre style="margin:0em;"><span style="color:#000000">}</span> <span style="color:#0000ff">else</span><span style="color:#000000"> <span style="color:#000000">{</span></pre><pre style="margin:0em;">pos1 = pos2;</pre><pre style="margin:0em;"><span style="color:#000000">}</span></pre><pre style="margin:0em;"><span style="color:#000000">}</span></pre><pre style="margin:0em;"><span style="color:#0000ff">if</span><span style="color:#000000"> (atPos == -1) <span style="color:#000000">{</span></pre><pre style="margin:0em;"><span style="color:#0000ff">return</span><span style="color:#000000"> <span style="color:#0000ff">false</span><span style="color:#000000"> ;</pre><pre style="margin:0em;"><span style="color:#000000">}</span></pre><pre style="margin:0em;"><span style="color:#0000ff">if</span><span style="color:#000000"> (atPos == 0) <span style="color:#000000">{</span></pre><pre style="margin:0em;"><span style="color:#0000ff">return</span><span style="color:#000000"> <span style="color:#0000ff">false</span><span style="color:#000000"> ;</pre><pre style="margin:0em;"><span style="color:#000000">}</span></pre><pre style="margin:0em;"><span style="color:#0000ff">if</span><span style="color:#000000"> (pPos1 == 0) <span style="color:#000000">{</span></pre><pre style="margin:0em;"><span style="color:#0000ff">return</span><span style="color:#000000"> <span style="color:#0000ff">false</span><span style="color:#000000"> ;</pre><pre style="margin:0em;"><span style="color:#000000">}</span></pre><pre style="margin:0em;"><span style="color:#0000ff">if</span><span style="color:#000000"> (email.indexOf(<span style="color:#800000">"@"</span><span style="color:#000000"> , atPos + 1) > -1) <span style="color:#000000">{</span></pre><pre style="margin:0em;"><span style="color:#0000ff">return</span><span style="color:#000000"> <span style="color:#0000ff">false</span><span style="color:#000000"> ;</pre><pre style="margin:0em;"><span style="color:#000000">}</span></pre><pre style="margin:0em;"><span style="color:#0000ff">if</span><span style="color:#000000"> (periodPos == -1) <span style="color:#000000">{</span></pre><pre style="margin:0em;"><span style="color:#0000ff">return</span><span style="color:#000000"> <span style="color:#0000ff">false</span><span style="color:#000000"> ;</pre><pre style="margin:0em;"><span style="color:#000000">}</span></pre><pre style="margin:0em;"><span style="color:#0000ff">if</span><span style="color:#000000"> (atPos + 1 == periodPos) <span style="color:#000000">{</span></pre><pre style="margin:0em;"><span style="color:#0000ff">return</span><span style="color:#000000"> <span style="color:#0000ff">false</span><span style="color:#000000"> ;</pre><pre style="margin:0em;"><span style="color:#000000">}</span></pre><pre style="margin:0em;"><span style="color:#0000ff">if</span><span style="color:#000000"> (periodPos + 3 > email.length) <span style="color:#000000">{</span></pre><pre style="margin:0em;"><span style="color:#0000ff">return</span><span style="color:#000000"> <span style="color:#0000ff">false</span><span style="color:#000000"> ;</pre><pre style="margin:0em;"><span style="color:#000000">}</span></pre><pre style="margin:0em;"><span style="color:#0000ff">return</span><span style="color:#000000"> <span style="color:#0000ff">true</span><span style="color:#000000"> ;</pre><pre style="margin:0em;"><span style="color:#000000">}</span></pre><pre style="margin:0em;"></pre><pre style="margin:0em;"><span style="color:#0000ff"></<span style="color:#800000">script<span style="color:#0000ff">></pre><pre style="margin:0em;"></pre></div><!-- End block -->sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-11619796902113155502011-06-15T04:56:00.000-07:002011-06-15T04:59:15.036-07:00Javascript function to check for valid characters and invalid characters<div dir="ltr" style="text-align: left;" trbidi="on">If you want to validate a name feild with only alphabets. you can use below code to validate it.<br />
<br />
<div style="color: black; overflow: auto; width: 99.5%;"><pre style="margin: 0em;"><span style="color: blue;"><<span style="color: maroon;">script</span><span style="color: black;"> <span style="color: red;">type<span style="color: blue;">="text/javascript"></span><span style="color: black;"> </span></span></span></span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> (IsValidChars(document.getElementById(<span'< span=""><span style="color: black;"> ).value.toLowerCase(), <span style="color: maroon;">"abcdefghijklmnopqrstuvwxyz"</span><span style="color: black;"> )) <span style="color: black;">{</span></span></span></span'<></span></pre><pre style="margin: 0em;">alert(<span style="color: maroon;">"valid"</span><span style="color: black;"> );</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: blue;">else</span><span style="color: black;"> <span style="color: black;">{</span></span></pre><pre style="margin: 0em;">alert(<span style="color: maroon;">"Invalid Characters"</span><span style="color: black;"> );</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: darkgreen;">//Function to check the valid characters</span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: blue;">function</span><span style="color: black;"> IsValidChars(Char_To_Be_Checked, Valid_Char) <span style="color: black;">{</span></span></pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> checkStr;</span></pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> checkOK1;</span></pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> allValid;</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;">checkStr = Char_To_Be_Checked;</pre><pre style="margin: 0em;">checkOK1 = Valid_Char;</pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> allValid = <span style="color: blue;">true</span><span style="color: black;"> ;</span></span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: blue;">for</span><span style="color: black;"> (m = 0; m < checkStr.length; m++) <span style="color: black;">{</span></span></pre><pre style="margin: 0em;">ch = checkStr.charAt(m);</pre><pre style="margin: 0em;"><span style="color: blue;">for</span><span style="color: black;"> (n = 0; n < checkOK1.length; n++) <span style="color: black;">{</span></span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> (ch == checkOK1.charAt(n))</span></pre><pre style="margin: 0em;"><span style="color: blue;">break</span><span style="color: black;"> ;</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> (n == checkOK1.length) <span style="color: black;">{</span></span></pre><pre style="margin: 0em;">allValid = <span style="color: blue;">false</span><span style="color: black;"> ;</span></pre><pre style="margin: 0em;"><span style="color: blue;">break</span><span style="color: black;"> ;</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: blue;">return</span><span style="color: black;"> allValid;</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: darkgreen;">//Function to check the invalid characters</span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: blue;">function</span><span style="color: black;"> IsInValidChars(Char_To_Be_Checked, InValid_Char) <span style="color: black;">{</span></span></pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> checkStr;</span></pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> checkOK1;</span></pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> allValid;</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;">checkStr = Char_To_Be_Checked;</pre><pre style="margin: 0em;">checkOK1 = InValid_Char;</pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> allValid = <span style="color: blue;">true</span><span style="color: black;"> ;</span></span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: blue;">for</span><span style="color: black;"> (m = 0; m < checkStr.length; m++) <span style="color: black;">{</span></span></pre><pre style="margin: 0em;">ch = checkStr.charAt(m);</pre><pre style="margin: 0em;"><span style="color: blue;">for</span><span style="color: black;"> (n = 0; n < checkOK1.length; n++) <span style="color: black;">{</span></span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> (ch == checkOK1.charAt(n)) <span style="color: black;">{</span></span></pre><pre style="margin: 0em;">allValid = <span style="color: blue;">false</span><span style="color: black;"> ;</span></pre><pre style="margin: 0em;"><span style="color: blue;">break</span><span style="color: black;"> ;</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: blue;">return</span><span style="color: black;"> allValid;</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span> </pre><pre style="margin: 0em;"><span style="color: blue;"></<span style="color: maroon;">script<span style="color: blue;">></span></span></span></pre><pre style="margin: 0em;"></pre></div><br />
<br />
</div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-6842378530447667442011-06-15T00:13:00.000-07:002011-06-15T00:13:43.839-07:00Trim String Using Javascript<div dir="ltr" style="text-align: left;" trbidi="on"><h2>Javascript Trim Member Functions</h2>Use the code below to make trim a method of all Strings. These are useful to place in a global Javascript file included by all your pages. <br />
<pre><code>
String.prototype.trim = function() {
return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
return this.replace(/\s+$/,"");
}</code></pre><pre><code> </code></pre><h2>Javascript Trim Stand-Alone Functions</h2>If you prefer not to modify the string prototype, then you can use the stand-alone functions below. <br />
<code> function trim(stringToTrim) { return stringToTrim.replace(/^\s+|\s+$/g,""); } function ltrim(stringToTrim) { return stringToTrim.replace(/^\s+/,""); } function rtrim(stringToTrim) { return stringToTrim.replace(/\s+$/,""); }</code><br />
<br />
<h2>Compatibility</h2>The functions above use regular expressions, which are compatible with Javascript 1.2+ or JScript 3.0+. All modern browsers will support this. If you require functions for older versions of Javascript back to version 1.0, try the functions below adapted from the <a href="http://www.jibbering.com/faq/#FAQ4_16">Javascript FAQ 4.16</a>. These strip the following, standard whitespace characters: space, tab, line feed, carriage return, and form feed. The IsWhitespace function checks if a character is whitespace. <br />
<pre><code>
function ltrim(str) {
for(var k = 0; k < str.length && isWhitespace(str.charAt(k)); k++);
return str.substring(k, str.length);
}
function rtrim(str) {
for(var j=str.length-1; j>=0 && isWhitespace(str.charAt(j)) ; j--) ;
return str.substring(0,j+1);
}
function trim(str) {
return ltrim(rtrim(str));
}
function isWhitespace(charToCheck) {
var whitespaceChars = " \t\n\r\f";
return (whitespaceChars.indexOf(charToCheck) != -1);
}
</code></pre><br />
<pre><code> </code></pre></div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-88475856753849553672011-06-14T23:37:00.000-07:002011-07-19T05:58:39.702-07:00LINQ to Excel using Dataset or Datatable<div dir="ltr" style="text-align: left;" trbidi="on"><br />
<div style="color: black; overflow: auto; width: 99.5%;"><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Collections;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Collections.Generic;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Data;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Diagnostics;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> TWebservice;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Xml;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Linq;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Xml.Linq;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Web;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Web.UI;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Web.UI.WebControls;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Data.SqlClient;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Web.Configuration;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Data.OleDb;</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: blue;">public</span><span style="color: black;"> <span style="color: blue;">partial</span><span style="color: black;"> <span style="color: blue;">class</span><span style="color: black;"> <span style="color: #2b91af;">Thanks</span><span style="color: black;"> : System.Web.UI.<span style="color: #2b91af;">Page</span><span style="color: black;"> </span></span></span></span></span></pre><pre style="margin: 0em;"><span style="color: black;">{</span></pre><pre style="margin: 0em;"><span style="color: green;">//Resturns the excel sheet as Dataset or DataTable</span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: blue;">private</span><span style="color: black;"> <span style="color: #2b91af;">DataTable</span><span style="color: black;"> GetExcel()</span></span></pre><pre style="margin: 0em;"><span style="color: black;">{</span></pre><pre style="margin: 0em;"><span style="color: #2b91af;">DataTable</span><span style="color: black;"> dataTable;</span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> (Cache[<span style="color: #a31515;">"ExcelDatas"</span><span style="color: black;"> ] == <span style="color: blue;">null</span><span style="color: black;"> )</span></span></span></pre><pre style="margin: 0em;"><span style="color: black;">{</span></pre><pre style="margin: 0em;"><span style="color: blue;">string</span><span style="color: black;"> filename = Server.MapPath(<span style="color: #a31515;">"~/Common_Inc/Country.xls"</span><span style="color: black;"> );</span></span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: blue;">string</span><span style="color: black;"> connectionString = <span style="color: #a31515;">"Provider=Microsoft.Jet.OLEDB.4.0;"</span><span style="color: black;"> + <span style="color: #a31515;">"Data Source="</span><span style="color: black;"> + filename + <span style="color: #a31515;">";"</span><span style="color: black;"> + <span style="color: #a31515;">"Extended Properties=Excel 8.0;"</span><span style="color: black;"> ;</span></span></span></span></span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: #2b91af;">OleDbDataAdapter</span><span style="color: black;"> dataAdapter = <span style="color: blue;">new</span><span style="color: black;"> <span style="color: #2b91af;">OleDbDataAdapter</span><span style="color: black;"> (<span style="color: #a31515;">"SELECT * FROM [citystatecountry]"</span><span style="color: black;"> , connectionString);<span style="color: green;">// [excel sheet name]</span><span style="color: black;"> </span></span></span></span></span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: #2b91af;">DataSet</span><span style="color: black;"> myDataSet = <span style="color: blue;">new</span><span style="color: black;"> <span style="color: #2b91af;">DataSet</span><span style="color: black;"> ();</span></span></span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;">dataAdapter.Fill(myDataSet, <span style="color: #a31515;">"ExcelInfo"</span><span style="color: black;"> );</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;">dataTable = myDataSet.Tables[<span style="color: #a31515;">"ExcelInfo"</span><span style="color: black;"> ];</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;">Cache[<span style="color: #a31515;">"ExcelDatas"</span><span style="color: black;"> ] = dataTable;</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: blue;">else</span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: black;">{</span></pre><pre style="margin: 0em;">dataTable = (<span style="color: #2b91af;">DataTable</span><span style="color: black;"> )Cache[<span style="color: #a31515;">"ExcelDatas"</span><span style="color: black;"> ];</span></span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: blue;">return</span><span style="color: black;"> dataTable;</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: blue;">protected</span><span style="color: black;"> <span style="color: blue;">void</span><span style="color: black;"> Page_Load(<span style="color: blue;">object</span><span style="color: black;"> sender, <span style="color: #2b91af;">EventArgs</span><span style="color: black;"> e)</span></span></span></span></pre><pre style="margin: 0em;"><span style="color: black;">{</span></pre><pre style="margin: 0em;"><span style="color: blue;">if</span><span style="color: black;"> (!IsPostBack)</span></pre><pre style="margin: 0em;"><span style="color: black;">{</span></pre><pre style="margin: 0em;"><span style="color: green;">//Now we can use LINQ to Dataset to query the data in Excel.</span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: #2b91af;">DataTable</span><span style="color: black;"> dataTable = GetExcel(); </span></pre><pre style="margin: 0em;"><span style="color: blue;">var</span><span style="color: black;"> ExcelDatas = (<span style="color: blue;">from</span><span style="color: black;"> r <span style="color: blue;">in</span><span style="color: black;"> dataTable.AsEnumerable().GroupBy(g => g.Field<<span style="color: blue;">string</span><span style="color: black;"> >(<span style="color: #a31515;">"Country"</span><span style="color: black;"> )).Select(f => f.First()) <span style="color: blue;">select</span><span style="color: black;"> <span style="color: blue;">new</span><span style="color: black;"> <span style="color: black;">{</span> Country = r.Field<<span style="color: blue;">string</span><span style="color: black;"> >(<span style="color: #a31515;">"Country"</span><span style="color: black;"> ) <span style="color: black;">}</span>).Distinct();</span></span></span></span></span></span></span></span></span></pre><pre style="margin: 0em;">ddlHomecountry.DataSource = ExcelDatas;</pre><pre style="margin: 0em;">ddlHomecountry.DataTextField = <span style="color: #a31515;">"Country"</span><span style="color: black;"> ;</span></pre><pre style="margin: 0em;">ddlHomecountry.DataValueField = <span style="color: #a31515;">"Country"</span><span style="color: black;"> ;</span></pre><pre style="margin: 0em;">ddlHomecountry.DataBind(); </pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre></div><br />
Update: This tutorial uses <span class="Apple-style-span" style="color: #a31515; font-family: monospace; white-space: pre;">Microsoft.Jet.OLEDB.4.0 </span><span class="Apple-style-span" style="font-family: monospace; white-space: pre;">provider for returning a Dataset from Excel. There is now a better tool to do it from codeplex. it has even support for 2007 office format. This tool is available at</span><span class="Apple-style-span" style="color: #a31515; font-family: monospace; white-space: pre;"> </span><a href="http://exceldatareader.codeplex.com/">http://exceldatareader.codeplex.com/</a></div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-20545459203600283802011-06-11T02:16:00.000-07:002011-06-11T02:19:37.636-07:00Error because of Child Applications reading values from Root web.config<div dir="ltr" style="text-align: left;" trbidi="on">Error because of Child Applications reading values from Root web.config.<br />
<br />
<br />
To prevent this add location tag with attribute inheritInChildApplications="false" to root web.config for the part which you do not want to inherit.<br />
<br />
<pre style="background-color: #fbfbfb; border-bottom: #cecece 1px solid; border-left: #cecece 1px solid; border-right: #cecece 1px solid; border-top: #cecece 1px solid; font-family: monospace; font-size: 12px; min-height: 40px; overflow: auto; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; padding-top: 5px; width: 650px;">[...]
<span style="color: blue;"><</span><span style="color: maroon;">location</span> <span style="color: red;">inheritInChildApplications</span>=<span style="color: blue;">"false"</span><span style="color: blue;">></span>
<span style="color: blue;"><</span><span style="color: maroon;">system.web</span><span style="color: blue;">></span>
[...]
<span style="color: blue;"><span style="color: maroon;">system.web</span><span style="color: blue;">></span>
<span style="color: blue;"><span style="color: maroon;">location</span><span style="color: blue;">></span>
[...]</span></span></pre><br />
<br />
If the error is caused by HttpHandler in root add validate="false" attribute to the handler which is causing the problem.<br />
<br />
<add path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha" validate="false" verb="GET"><add path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha" validate="false" verb="GET"></add></add><br />
<add path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha" validate="false" verb="GET"><br />
</add><br />
<add path="CaptchaImage.axd" type="MSCaptcha.CaptchaImageHandler, MSCaptcha" validate="false" verb="GET"><br />
</add><br />
<br />
<br />
<div style="color: black; overflow: auto; width: 99.5%;"><pre style="margin: 0em;"><span style="color: blue;"><<span style="color: #a31515;">add<span style="color: blue;"> <span style="color: red;">verb<span style="color: blue;">=</span><span style="color: black;"> "<span style="color: blue;">GET</span><span style="color: black;"> "<span style="color: blue;"> <span style="color: red;">path<span style="color: blue;">=</span><span style="color: black;"> "<span style="color: blue;">CaptchaImage.axd</span><span style="color: black;"> "<span style="color: blue;"> <span style="color: red;">validate<span style="color: blue;">=</span><span style="color: black;"> "<span style="color: blue;">false</span><span style="color: black;"> "<span style="color: blue;"> <span style="color: red;">type<span style="color: blue;">=</span><span style="color: black;"> "<span style="color: blue;">MSCaptcha.CaptchaImageHandler, MSCaptcha</span><span style="color: black;"> "<span style="color: blue;">/></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></span></pre><pre style="margin: 0em;"></pre></div></div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-8494620841307753152011-06-08T02:24:00.000-07:002011-06-08T02:24:52.192-07:00Invalidate Output Cache when aspx or aspx.cs file changes<div dir="ltr" style="text-align: left;" trbidi="on">Invalidate Output Cache when aspx or aspx.cs file changes.<br />
<br />
To do this add file dependency object to response object.<br />
<br />
Set expires header.<br />
<br />
Set cache location as server and private(client,proxy).<br />
<br />
Generate Etag from file dependency(if you chnage the file<br />
before expire header date - this will load new file<br />
from server) - you must set<span style="color: #2b91af;"> HttpCacheability</span><span style="color: black;"> .ServerAndPrivate </span><br />
<span style="color: black;">for Etag to work.</span><br />
<pre style="margin: 0em;"><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: black;">Override Render event to minify HTML output.</span></pre><pre style="margin: 0em;"><span style="color: black;">This will save bandwidth.</span></pre><pre style="margin: 0em;"><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: black;">In order to add this functionality </span></pre><pre style="margin: 0em;"><span style="color: black;">to all the pages i have inherited page class</span></pre><pre style="margin: 0em;"><span style="color: black;"> and created custom Page class called </span><span style="color: grey;"><span style="color: green;">MyPage</span><span style="color: black;">.</span></span></pre><pre style="margin: 0em;"><span style="color: grey;"><span style="color: black;"> </span></span></pre><pre style="margin: 0em;"><b><span style="font-size: large;"><span style="color: black;">Complete Code below. </span></span></b><span style="color: grey;"><span style="color: black;"><b><span style="font-size: large;"> </span></b></span></span></pre><pre style="margin: 0em;"><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: black;"> </span></pre><div style="color: black; overflow: auto; width: 99.5%;"><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Web.Caching;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Web.UI;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Web;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Reflection;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.IO;</span></pre><pre style="margin: 0em;"><span style="color: blue;">using</span><span style="color: black;"> System.Text.RegularExpressions;</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: grey;">///<span style="color: green;"> <span style="color: grey;"><summary></span><span style="color: black;"> </span></span></span></pre><pre style="margin: 0em;"><span style="color: grey;">///<span style="color: green;"> Summary description for MyPage</span><span style="color: black;"> </span></span></pre><pre style="margin: 0em;"><span style="color: grey;">///<span style="color: green;"> <span style="color: grey;"></summary></span><span style="color: black;"> </span></span></span></pre><pre style="margin: 0em;"><span style="color: blue;">public</span><span style="color: black;"> <span style="color: blue;">partial</span><span style="color: black;"> <span style="color: blue;">class</span><span style="color: black;"> <span style="color: #2b91af;">MyPage</span><span style="color: black;"> : <span style="color: #2b91af;">Page</span><span style="color: black;"> </span></span></span></span></span></pre><pre style="margin: 0em;"><span style="color: black;">{</span></pre><pre style="margin: 0em;"><span style="color: blue;">protected</span><span style="color: black;"> <span style="color: blue;">void</span><span style="color: black;"> Page_Init(<span style="color: blue;">object</span><span style="color: black;"> sender, <span style="color: #2b91af;">EventArgs</span><span style="color: black;"> e)</span></span></span></span></pre><pre style="margin: 0em;"><span style="color: black;">{</span></pre><pre style="margin: 0em;"><span style="color: blue;">string</span><span style="color: black;"> [] fileDependencies;</span></pre><pre style="margin: 0em;"><span style="color: blue;">string</span><span style="color: black;"> fileDependency1 = Server.MapPath(Request.Url.LocalPath);</span></pre><pre style="margin: 0em;"><span style="color: blue;">string</span><span style="color: black;"> fileDependency2 = Server.MapPath(Request.Url.LocalPath).Replace(<span style="color: #a31515;">".aspx"</span><span style="color: black;"> ,<span style="color: #a31515;">".aspx.cs"</span><span style="color: black;"> );</span></span></span></pre><pre style="margin: 0em;">fileDependencies = <span style="color: blue;">new</span><span style="color: black;"> <span style="color: blue;">string</span><span style="color: black;"> [] <span style="color: black;">{</span> fileDependency1, fileDependency2 <span style="color: black;">}</span>;</span></span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: green;">//Uncomment before going to live.</span><span style="color: black;"> </span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;">Response.AddFileDependencies(fileDependencies);</pre><pre style="margin: 0em;">Response.Cache.SetVaryByCustom(<span style="color: #a31515;">"browser"</span><span style="color: black;"> );</span></pre><pre style="margin: 0em;">Response.Cache.SetExpires(<span style="color: #2b91af;">DateTime</span><span style="color: black;"> .Now.AddDays(1));</span></pre><pre style="margin: 0em;">Response.Cache.SetCacheability(<span style="color: #2b91af;">HttpCacheability</span><span style="color: black;"> .ServerAndPrivate);</span></pre><pre style="margin: 0em;">Response.Cache.SetETagFromFileDependencies();</pre><pre style="margin: 0em;">Response.Cache.SetValidUntilExpires(<span style="color: blue;">true</span><span style="color: black;"> );</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre><pre style="margin: 0em;"><span style="color: green;">//Override the page Render event to minify HTML output.</span><span style="color: black;"> </span></pre><pre style="margin: 0em;"><span style="color: blue;">protected</span><span style="color: black;"> <span style="color: blue;">override</span><span style="color: black;"> <span style="color: blue;">void</span><span style="color: black;"> Render(<span style="color: #2b91af;">HtmlTextWriter</span><span style="color: black;"> writer)</span></span></span></span></pre><pre style="margin: 0em;"><span style="color: black;">{</span></pre><pre style="margin: 0em;"><span style="color: #2b91af;">TextWriter</span><span style="color: black;"> output = <span style="color: blue;">new</span><span style="color: black;"> <span style="color: #2b91af;">StringWriter</span><span style="color: black;"> ();</span></span></span></pre><pre style="margin: 0em;"><span style="color: blue;">base</span><span style="color: black;"> .Render(<span style="color: blue;">new</span><span style="color: black;"> <span style="color: #2b91af;">HtmlTextWriter</span><span style="color: black;"> (output));</span></span></span></pre><pre style="margin: 0em;"><span style="color: #2b91af;">String</span><span style="color: black;"> html = output.ToString();</span></pre><pre style="margin: 0em;">html = <span style="color: #2b91af;">Regex</span><span style="color: black;"> .Replace(html, <span style="color: #a31515;">@"\n|\t"</span><span style="color: black;"> , <span style="color: #a31515;">" "</span><span style="color: black;"> );</span></span></span></pre><pre style="margin: 0em;">html = <span style="color: #2b91af;">Regex</span><span style="color: black;"> .Replace(html, <span style="color: #a31515;">@">\\s+<"</span><span style="color: black;"> , <span style="color: #a31515;">"><"</span><span style="color: black;"> ).Trim();</span></span></span></pre><pre style="margin: 0em;">html = <span style="color: #2b91af;">Regex</span><span style="color: black;"> .Replace(html, <span style="color: #a31515;">@"\\s<span style="color: black;">{</span>2,<span style="color: black;">}</span>"</span><span style="color: black;"> , <span style="color: #a31515;">" "</span><span style="color: black;"> );</span></span></span></pre><pre style="margin: 0em;">writer.Write(html);</pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"><span style="color: black;">}</span></pre><pre style="margin: 0em;"></pre></div>if you want to invalidate cache manually. you can use the below method to do the task.<br />
<br />
<h1 class="title"><span style="font-size: large;">Response</span><span style="font-size: large;">.RemoveOutputCacheItem Method (String)</span></h1><h1 class="title"> </h1><br />
</div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com1tag:blogger.com,1999:blog-259724367068365482.post-23447498934947176262011-06-03T04:02:00.001-07:002011-06-03T04:02:38.163-07:00Updatable Views<div dir="ltr" style="text-align: left;" trbidi="on"><h3 class="subHeading"></h3><div class="subsection"> You can modify the data of an underlying base table through a view, as long as the following conditions are true: <br />
<ul><li> Any modifications, including UPDATE, INSERT, and DELETE statements, must reference columns from only one base table. <br />
</li>
<li> The columns being modified in the view must directly reference the underlying data in the table columns. The columns cannot be derived in any other way, such as through the following: <br />
<ul><li> An aggregate function: AVG, COUNT, SUM, MIN, MAX, GROUPING, STDEV, STDEVP, VAR, and VARP.<br />
</li>
<li> A computation. The column cannot be computed from an expression that uses other columns. Columns that are formed by using the set operators UNION, UNION ALL, CROSSJOIN, EXCEPT, and INTERSECT amount to a computation and are also not updatable.<br />
</li>
</ul></li>
<li> The columns being modified are not affected by GROUP BY, HAVING, or DISTINCT clauses.<br />
</li>
<li> TOP is not used anywhere in the <span class="parameter">select_statement</span> of the view together with the WITH CHECK OPTION clause.<br />
</li>
</ul>The previous restrictions apply to any subqueries in the FROM clause of the view, just as they apply to the view itself. Generally, the Database Engine must be able to unambiguously trace modifications from the view definition to one base table. For more information, see <span><a href="http://msdn.microsoft.com/en-us/library/ms180800.aspx">Modifying Data Through a View</a></span>. <br />
If the previous restrictions prevent you from modifying data directly through a view, consider the following options: <br />
<ul><li> <span class="label">INSTEAD OF Triggers</span> <br />
INSTEAD OF triggers can be created on a view to make a view updatable. The INSTEAD OF trigger is executed instead of the data modification statement on which the trigger is defined. This trigger lets the user specify the set of actions that must happen to process the data modification statement. Therefore, if an INSTEAD OF trigger exists for a view on a specific data modification statement (INSERT, UPDATE, or DELETE), the corresponding view is updatable through that statement. For more information about INSTEAD OF triggers, see <span><a href="http://msdn.microsoft.com/en-us/library/ms175521.aspx">Designing INSTEAD OF Triggers</a></span>.<br />
</li>
<li> <span class="label">Partitioned Views</span> <br />
If the view is a partitioned view, the view is updatable, subject to certain restrictions. When it is needed, the Database Engine distinguishes local partitioned views as the views in which all participating tables and the view are on the same instance of SQL Server, and distributed partitioned views as the views in which at least one of the tables in the view resides on a different or remote server. <br />
For more information about partitioned views, see <span><a href="http://msdn.microsoft.com/en-us/library/ms181036.aspx">Creating Partitioned Views</a></span>.<br />
</li>
</ul></div></div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-27342086028411081472011-05-29T23:52:00.000-07:002011-05-29T23:52:20.180-07:00XML parsing failed - Opera<div dir="ltr" style="text-align: left;" trbidi="on">This mostly occurs with ASP.NET as it sets content type for opera as application/xhtml+xml.This error occurs in opera if you have any unescaped html special characters in aspx page Eg: & instead of & . Validate your page using W3C validator for any page errors. If it occurs for a existing large scale website. go ahead and fix it using browser config file hack.You will face this issue if you add browser config files from codeplex to detect mobile devices such as http://mdbf.codeplex.com.<br />
In order to over come this issue. You need to set content type to text/html. <br />
The best way to fix this issue is to add following code to .browser config file for opera in App_Browser file.<br />
<br />
<capability name="preferredRenderingMime" value="text/html" /><br />
<capability name="preferredRenderingType" value="html32" /><br />
<capability name="SupportsXhtmlRendering" value="false" /></div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0tag:blogger.com,1999:blog-259724367068365482.post-70521470378274015282011-05-16T04:32:00.000-07:002011-05-16T04:32:03.490-07:00Delegates and events:<div dir="ltr" style="text-align: left;" trbidi="on"> <br />
<div style="margin-bottom: 0in;">Delegates and events:</div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;">Handle or Subscribe to ASP.NET Controls events from UserControl in ASPX Page.</div><div style="margin-bottom: 0in;"><br />
</div><div style="background-color: #cfe2f3; margin-bottom: 0in;"><u><b>Step 1:</b></u></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;">Create a usercontrol having a textbox and button control</div><div style="margin-bottom: 0in;"><br />
</div><span style="color: blue;"><span style="font-size: x-small;"><span style="font-family: Courier New,monospace;">Search Catalogue by Points <br><br><br />
<br />
<asp:Panel ID="Panel1" runat="server" DefaultButton="btnSubmit"><br />
<br />
<input type="text" name="Text1" size="4" maxlength="6" ID="Text1" runat="server"/><br />
<br />
<asp:Button ID="btnSubmit" runat="server" Text="Go"<br />
<br />
OnClientClick="javascript:return clickherego(this.form);"<br />
<br />
style="color:White;background-color:#75bde9;border-style:None;width:25px;height:20px;font-size:10px;font-family:verdana"<br />
<br />
onclick="btnSubmit_Click"/> </asp:Panel></span></span></span><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">Explanation:</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: red;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">DefaultButton</span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">="btnSubmit" </span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">in panel control will trigger btnSubmit button click when user presses enter key or return key in Mac.</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><u><b>Step 2:</b></u></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">Inherit EventArgs Class to Pass values to Event Handler. This will enable us to get the user control textbox values in ASPX page.</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">public</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">class</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">NavEventArgs</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> : </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">EventArgs</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">{</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">private</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">int</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> _text;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">public</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">int</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> SearchText</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">{</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">get</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> { </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">return</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> _text; }</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">}</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">public</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> NavEventArgs(</span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">int</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> searchtext)</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">{</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">this</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">._text = searchtext;</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">}</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">}</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><u><b>Step 3:</b></u></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">Create an event in UserControl1.ascx.cs file</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">private</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">bool</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> _goClicked;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">public</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">bool</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> GoClicked</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">{</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">get</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> { </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">return</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> _goClicked; }</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">set</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> { _goClicked = </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">value</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">; }</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">}</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">private</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">int</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> _text1value;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">public</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">int</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> Text1Value</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">{</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">get</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> { </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">return</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> _text1value; }</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">set</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> { _text1value = </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">value</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">; }</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">}</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">public</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">delegate</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">void</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">NavEventHandler</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">(</span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">object</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> sender, </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">NavEventArgs</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> e );</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">public</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">event</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">NavEventHandler</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> GoButtonClicked;</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><u><b>Step 4:</b></u></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">Fire the </span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">GoButtonClicked </span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">event in submit button clicked event. </span></span></span> </div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">protected</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">void</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> btnSubmit_Click(</span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">object</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> sender, </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">EventArgs</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> e)</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">{</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span> </div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">GoClicked = </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">true</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">Text1Value = </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">Convert</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">.ToInt32(Text1.Value);</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">Text1.Value = </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">string</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">.Empty;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">if</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> (GoButtonClicked != </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">null</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">)</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">{</span></span></span></div><div style="margin-bottom: 0in;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"><span style="color: black;"> //this value can be accessed using </span>e.SearchText<span style="color: black;"> in EventHandler </span></span></span> </div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">NavEventArgs</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> e1 = </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">new</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">NavEventArgs</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">(Text1Value);</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> //Fire the event</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">GoButtonClicked(</span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">this</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">, e1);</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">}</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span> </div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">}</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;">Entire UserControl1.ascx.cs file</div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"> </div><div style="margin-bottom: 0in;"><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">using</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> System;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">using</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> System.Data;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">using</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> System.Configuration;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">using</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> System.Collections;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">using</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> System.Web;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">using</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> System.Web.Security;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">using</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> System.Web.UI;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">using</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> System.Web.UI.WebControls;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">using</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> System.Web.UI.WebControls.WebParts;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">using</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> System.Web.UI.HtmlControls;</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">public</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">partial</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">class</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">dinning_navigation</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> : System.Web.UI.</span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">UserControl</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">{</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">private</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">bool</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> _goClicked;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">public</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">bool</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> GoClicked</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">{</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">get</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> { </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">return</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> _goClicked; }</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">set</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> { _goClicked = </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">value</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">; }</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">}</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">private</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">int</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> _text1value;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">public</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">int</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> Text1Value</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">{</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">get</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> { </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">return</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> _text1value; }</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">set</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> { _text1value = </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">value</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">; }</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">}</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">public</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">delegate</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">void</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">NavEventHandler</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">(</span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">object</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> sender, </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">NavEventArgs</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> e );</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">public</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">event</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">NavEventHandler</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> GoButtonClicked;</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">protected</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">void</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> Page_Load(</span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">object</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> sender, </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">EventArgs</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> e)</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">{</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span> </div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">GoClicked = </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">false</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span> </div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">Text1.Attributes.Add(</span></span></span><span style="color: #a31515;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">"onkeydown"</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">, </span></span></span><span style="color: #a31515;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">"if(event.keyCode== 13){document.getElementById('"</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> + btnSubmit.UniqueID + </span></span></span><span style="color: #a31515;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">"').click();}"</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">);</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">}</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span> </div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">protected</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">void</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> btnSubmit_Click(</span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">object</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> sender, </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">EventArgs</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> e)</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">{</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: green;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">//Response.Redirect("search_result.aspx?text=" + Text1.Value);</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">GoClicked = </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">true</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">Text1Value = </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">Convert</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">.ToInt32(Text1.Value);</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">Text1.Value = </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">string</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">.Empty;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">if</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> (GoButtonClicked != </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">null</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">)</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">{</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">NavEventArgs</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> e1 = </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">new</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">NavEventArgs</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">(Text1Value);</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">GoButtonClicked(</span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">this</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">, e1);</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">}</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span> </div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">}</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">}</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">public</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">class</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">NavEventArgs</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> : </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">EventArgs</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">{</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">private</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">int</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> _text;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">public</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">int</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> SearchText</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">{</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">get</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> { </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">return</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> _text; }</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">}</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">public</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> NavEventArgs(</span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">int</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> searchtext)</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">{</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> </span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">this</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">._text = searchtext;</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">}</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">}</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"> </div><div style="margin-bottom: 0in;"><u><b>Step 5:</b></u></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">Handle </span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">GoButtonClicked event in ASPX </span></span></span> </div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><u><b>Step 5.1:</b></u></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">Add the user control to EventsTest.aspx page</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div><span style="color: blue;"><span style="font-size: x-small;"><span style="font-family: Courier New,monospace;"><%@ Register Src="dinning_navigation.ascx" TagName="dinning_navigation" TagPrefix="uc1" %><br />
<br />
<uc1:dinning_navigation ID="Dinning_navigation1" runat="server" OnGoButtonClicked="dinning_navigation_GoButtonClicked" /></span></span></span><div style="margin-bottom: 0in;"><br />
</div><u><b>Step 5.2:</b></u><br />
<br />
<div style="margin-bottom: 0in;">Event Handler for GoButtonClicked. Now <span style="color: red;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">OnGoButtonClicked </span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">event will automatically showed by Intellisense in visual studio. </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">dinning_navigation_GoButtonClicked </span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">is the EventHandler name I have given.</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: red;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">OnGoButtonClicked</span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">="dinning_navigation_GoButtonClicked"</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><u><b>Step 5.3:</b></u></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">EventHandler for </span></span></span><span style="color: red;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">GoButtonClicked </span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">event in Even</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">tsTest.aspx.cs file.</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div><div style="margin-bottom: 0in;"><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">protected</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> </span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">void</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> dinning_navigation_GoButtonClicked(</span></span></span><span style="color: blue;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">object</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> sender, </span></span></span><span style="color: #2b91af;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">NavEventArgs</span></span></span><span style="color: black;"><span style="font-family: Courier New,monospace;"><span style="font-size: x-small;"> e)</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">{</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">FillGrid4GoButtonClicked(e.SearchText);</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">GridView1.PageIndex = 0;</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">GridView1.DataBind();</span></span></span></div><div style="margin-bottom: 0in;"><span style="color: black;"> <span style="font-family: Courier New,monospace;"><span style="font-size: x-small;">}</span></span></span></div><div style="margin-bottom: 0in;"><br />
</div></div>sriram shttp://www.blogger.com/profile/10378901413704192523noreply@blogger.com0