Skip to main content

Posts

reCAPTCHA for ASP.NET

I was looking for this reCAPTCHA recently and this is what I found on my way. Hope this will help you in someway. To get an idea about reCAPTCHA watch the following video and the following link will explain you how to implement it in your ASP.net web site. reCAPTCHA for ASP.NET

Exit a T-SQL Cursor When Condition is met

Have you ever wanted to exit from a cursor when a condition is met? I wanted to do it. So this is how I did it. DECLARE @Field1 AS INT DECLARE @Field2 AS INT DECLARE CursorName CURSOR READ_ONLY FOR SELECT Field1, Field2 FROM TableName OPEN CursorName FETCH NEXT FROM CursorName INTO @Field1, @Field2 WHILE @@FETCH_STATUS = 0 BEGIN IF @Field1 = 1 BEGIN GOTO ENDCURSOR END FETCH NEXT FROM CursorName INTO @Field1, @Field2 END ENDCURSOR: CLOSE CursorName DEALLOCATE CursorName I have set my fonts to bold where you want to notice. So that's all I hope you will get something out of it and it is true that this is not a big deal. :)

Populate Modal popup data which is bind to a link button - ASP.net

I wanted to do a POC to my client to show modal popup functionality. So I did a simple page with one Button and a TextBox. That Button is responsible to popup the modal window. On that ModalPopup I implemented a search mechanism. I used Girdview control to show the search result. I wanted to populate the id value of that search result which was binded to a link button. This gridview and the text box and button was in a AJAX update panel control. I did this because I wanted to have the smothness of the UI. Now I met a new problem. Because I wanted to get that value out of that LinkButton control and show it in a TextBox control which was out of the ModalPopup. So what I did was, I just assign that LinkButton's text property to a HiddenField and I used a JavaScript function to populate that HiddenField value the TextBox. As you all know we need a Panel control to show our ModalPopup. This is gonna be a <div> on the HTML. So I used the onblur event to call my JavaScript functi...

Programmatically add the META tags to an ASP.NET page

Do you want to programmatically add the META tags to an ASP.NET page? You can try to the below code: HtmlMeta metaDesc = new HtmlMeta(); metaDesc.Name = "description" ; metaDesc.Content = "Your Description goes here" ; Page.Header.Controls.Add(metaDesc); HtmlMeta metaKey = new HtmlMeta(); metaKey.Name = "keywords" ; metaKey.Content = "Your keywords here" ; Page.Header.Controls.Add(metaKey);

Adding a separator image to ASP.Net Menu Control

This what I did to add a separator to ASP.Net menu. I used Web.sitemap to bind the data to menu control. This how Web.sitemap looks like. <sitemap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0"> <sitemapnode> <sitemapnode url="~/Pages/DatingHome.aspx" title="Home" description="" separatorImageUrl="../../Images/but_blueSlice.jpg"> <sitemapnode url="~/Pages/Inbox.aspx" title="Inbox" description="" separatorImageUrl="../../Images/but_blueSlice.jpg"> </sitemapnode> </sitemapnode> This separatorImageUrl will tell you the image path of the separator. This event handler will do the rest of it. protected void Menu2_MenuItemDataBound(object sender, System.Web.UI.WebControls.MenuEventArgs e) { SiteMapNode smNode = (SiteMapNode)e.Item.DataItem; if (smNode["seperatorImageUrl"] != null) e.Item.SeparatorImageUrl = smNode[...

How to configure SQL Server Session State with Custom Database

There are two steps got to follow to enable the SQL Server Session state to work 1. Configuring the database to support the SQL Server Session state. 2. Configuring your application to use SQL Server Session state. 1. Configuring the database to support the SQL Server Session state. .Net framework has a tool aspnet_regsql which you can use to add the table and stored procedure to support SQL Server Session state. You can find this tool in the following folder. C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\ aspnet_regsql.exe You can run this exe from window command prompt or you can directly run from SDK Command prompt. Executing the following command enables SQL Server Session state for a database server named local and store it in a custom database called CustomSessionDB. aspnet_regsql -C "Data Source=local;User Id=sa; Password=Sql2005" -ssadd -sstype c -d CustomSessionDB Executing this command creates a new database named CustomSessionDB that contains bot...