Posts

Showing posts from October, 2009

What this could be?

Image
Is this not a bug in windows XP? ----------------------- Desclimer: What ever you read here is out of my own experience. No one shall be made responsible for the contents and issues that are mentioned here.

What happen when we add runat=“server”

We all know that there are 2 types of controls that are available while developing web applications. They are HTML Controls as well as Server Controls. The main difference between these two controls is just the runat attribute. For any normal HTML Control like input, it becomes server control when you add the runat=“server” attribute. By adding this attribute, we can work with the control at code behind directly with out having any difficulties. But did you ever thought what happens when you add this attribute? The secret is that, the visual studio IDE creates a .designer.cs file as a code base for our .aspx page. This code base file is automatically generated, and we have nothing to do there. The purpose of this code base is to construct the controls that have the runat attribute. What do you say?

Enabling / Disabling Required Field Validator using JavaScript

Image
In our current application there is a requirement in one of the pages that when the an user is requesting for a some information, there are some options like Passport Number, Social Security Number are optional values to be submitted. And the client wanted them to be check boxes, because, the end user may submit more than one values. Here comes the actual trick, when the end user selected any one option, the text box next to that should be required. The UI would be some thing like the below   And the code for that is as mentioned below < asp : CheckBox ID ="cbPassport" runat ="server" Text ="Passport Number" onclick ="disableRFV(1)" /> < asp : TextBox ID ="txtPassportNumber" runat ="server"></ asp : TextBox > &nbsp; < asp : RequiredFieldValidator ID ="rfvPassport" Enabled ="false" Display ="Dynamic" EnableClientScript ="true" ControlToValidate ="txtPasspo

GridView with Hyperlink

Recently we have encountered a requirement where there is a page with simple details and a link for each record in that page take you to another page. This another page would have all the details of the selected record of the previous page. Let me rename these as ClassRoomPage containing the names of the students and their respective roll numbers and the second page is StudentDetailsPage where we pass a parameter as Student ID. So what we did is, we had the first page as ClassRoomPage with GridView and binded that with the respective columns. The trick is that we need a hyperlink to navigate to the next page along with the query parameter. So we added a template column with the hyperlink as mentioned below < asp : TemplateField HeaderText ="Comment"> < ItemTemplate > < asp : HyperLink id ="hlview" runat ="server" NavigateUrl =' <% #"~/StudentDetails.aspx?RollNumber="+ Eval("RollNum") %>

Month Name from Month number

Today, there was a requirement to show the month name in a text box. There are two forms that we have to show, depending on the user choice. The choices being the full name of the month as well as short name. Something similar to that of “October” for full name and “Oct” for short name. We know that we get the month number from DateTime object. This DateTime object has many properties that are directly associated to show the different parameters of Date and Time of the day. But now, for our requirement, you can get the full name of the month with the help of the Globalization object. That is too complicated. The simple method is to use the ToString() with the format that is required. DateTime .Now.ToString( "MMMM" ) Give you full name DateTime .Now.ToString( "MMM" ) returns you short name as required How is this?