Archive

Posts Tagged ‘ajax toolkit’

Solving Calendar Extender Problem in Modal Popup Extender Asp.net

September 13, 2010 3 comments

Calendar Extender control when placed inside modal popup extender will not be seen in front. To solve this issue, we have the following solution


<cc1:CalendarExtender ID="CalendarExtender1" TargetControlID="Textbox1"
 PopupPosition="Right" runat="server" <strong>OnClientShown="CalendarShown"></strong> </cc1:CalendarExtender>
<pre>
function calendarShown(sender, args)
    {
        sender._popupBehavior._element.style.zIndex = 10005;
    }
Advertisements

Textbox Watermark using Ajaxtoolkit or By Javascript

August 31, 2009 2 comments

Adding Watermark to textbox can be done in two ways:

1) Using Ajax Toolkit:

<asp:TextBox runat=”server” id=”txtname”/>

<ajaxToolkit:TextBoxWatermarkExtender ID="TBWE2" runat="server"
    TargetControlID="TextBox1"
    WatermarkText="Type First Name Here"
    WatermarkCssClass="watermarked" />

For more information on Ajax Toolkit please visit:
http://www.asp.net/ajax/

2) Using Javascript:

<asp:TextBox ID=”txtname” runat=”server” Text = “Please Enter your Name here”
 onblur = “TextboxWaterMark(this, event);”
 onfocus = “TextboxWaterMark(this, event);”>
 </asp:TextBox>

<script type = “text/javascript”>
 var Text = “Please Enter your text here”;//black

 function TextboxWaterMark(txtid, evnt)
 {
 if(txtid.value.length == 0 && evnt.type == “blur”)
 {
 txtid.style.color = “set the color you want”;//red
 txtid.value = Text;
 }
 if(txtid.value == Text && evnt.type == “focus”)
 {
 txtid.style.color = “set the color you want”;
 txtid.value=”";
 }
 }
 </script>

To use in code behind :

 txtname.Attributes.Add(”onblur”, “TextboxWaterMark(this, event);”);

 txtname.Attributes.Add(”onfocus”, “TextboxWaterMark(this, event);”);