Home > Asp.net > Calendar Extender and Textbox set to Read only in Asp.net – C#

Calendar Extender and Textbox set to Read only in Asp.net – C#


Lets say we have a textbox control and calendar extender associated with it.Now if we want to set the textbox to read only mode, we set Readonly = true

But there is a problem with it.

Setting the readonly atrribute as stated here will not cause any serverside processing to occur. If you need the value in the textbox to be available serverside then use the attribute

contentEditable="false" 

rather than read only. This only works for IE browsers however.

so the code becomes.

<asp:TextBox ID=”txtDate” contentEditable=”false” runat=”server” CssClass=”txtcss”></asp:TextBox>&nbsp;
<asp:Image ID=”imgCal” runat=”server” ImageUrl=”~/img/calendar.gif” />
<cc1:CalendarExtender ID=”CalExtDate” runat=”server”  PopupButtonID=”imgCal”
PopupPosition=”BottomLeft” Format=”dd/MM/yyyy”    TargetControlID=”txtDate”>
</cc1:CalendarExtender>

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: