Skip to main content

Posts

Showing posts from 2008

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

Simulate Table Lock situation using a Select statement - SQL Server 2005

Today I wanted simulate a table lock situation in my database using a select statement. It was bit hard for me to do it. I was searching it in web, but couldn't find useful thing. May be I didn't do it in right way. ;) Anyway I could do it. This is how I did it. You can write your SQL statement with (TABLOCKX) at the end of SQL statement. ex: Select * From table_name (TABLOCKX) I assume you all know how to do the rest of it.

How to use DataBinder.Eval in HyperLink NavigationUrl - ASP.net

I wanted to append page Url with DataBinder.Eval value in ASP.NET hyperlink control on ASP.NET HTML source. I was trying it using many ways and also search for resources on web but I could not find any useful thing. I thought this will help u guys to get an idea about appending two strings. Solution as follows. <asp:HyperLink ID="customerHyperLink" runat="server" Text= '<%# DataBinder.Eval(Container.DataItem, "Name") %>' NavigateUrl='<%# "~/Pages/YourPage.aspx?id=" + DataBinder.Eval(Container.DataItem, "id") %>' ></asp:HyperLink> You can see how I have appended these two value in NavigateUrl property. Hope some one will get the advantage of this post.

How To Implement Forms-Based Authentication in Your ASP.NET Application by Using C# .NET

These days I was so busy to find how to Implement form based authentication in my ASP.net application. I was looking for a resource that I can use on web. I found some and most of them are not that easy to understand. So I though to write an article so then any one can read and get the basic idea from it. I will first explain what is my scenario. I have my own database table to keep user credentials. So I wanted to use it to authenticate the users who are trying to log in. This has nothing more than configuring your Web.config and writing few codes authenticate the user. If you have your own database table to keep user credential, obviously you have a method written to authenticate. We can use this method to validate user and based on the results of this method you can do the authentication part. These are the configuration lines that you have to put in to our Web.config. <authentication mode="Forms"> <authentication mode="Forms"> <forms login

How To: Use Forms Authentication with Active Directory in ASP.NET 2.0

This post will show you how to use forms authentication with Microsoft Active Directory directory service by using the ActiveDirectoryMembershipProvider . To create a Web application with a logon page Start Microsoft Visual Studio® .NET development system, and then create a new ASP.NET Web site called FormsAuthAD. Use Solution Explorer to add a new Web form to the site called Login.aspx. Add a Login control to Login.aspx. By default, this control displays a user name field, a password field, and a Remember me next time checkbox. If the user selects this checkbox, a persistent authentication cookie is created and the user's browser stores the cookie on the user's computer. For security reasons, you should avoid creating persistent authentication cookies; therefore, disable this feature by setting the DisplayRememberMe property of the Login control to false . Note that when a user clicks Login on the Login control, it automatically validates the user by calling the con