LanceZhang’s Blog

Dear friends, Welcome to my blog.

Change the icon of ValidatorCalloutExtender

We can use the WarningIconImageUrl=”me.jpg” to achieve the facing goal:
 
 

<%@ Page Language=”C#” %>

<%@ Register Assembly=”AjaxControlToolkit” Namespace=”AjaxControlToolkit” TagPrefix=”cc1″ %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;

<script runat=“server”>

</script>

<html xmlns=http://www.w3.org/1999/xhtml&#8221;>
<head runat=“server”>
    <title></title>
</head>
<body>
    <form id=“form1” runat=“server”>
    <div>
        <cc1:ToolkitScriptManager ID=“ToolkitScriptManager1” runat=“server”>
        </cc1:ToolkitScriptManager>
        <asp:TextBox ID=“TextBox1” runat=“server”></asp:TextBox>
        <asp:RequiredFieldValidator ID=“RequiredFieldValidator1” Display=“None” runat=“server”
            ControlToValidate=“TextBox1” ErrorMessage=“RequiredFieldValidator”></asp:RequiredFieldValidator>
        <cc1:ValidatorCalloutExtender ID=“RequiredFieldValidator1_ValidatorCalloutExtender”
            runat=“server” Enabled=“True” TargetControlID=“RequiredFieldValidator1” WarningIconImageUrl=“me.jpg”>
        </cc1:ValidatorCalloutExtender>
    </div>
    <asp:Button ID=“Button1” runat=“server” Text=“Button” />
    </form>
</body>
</html>

Advertisements

October 31, 2008 Posted by | ASP.NET AJAX | | Leave a comment

MaskedEdit date for dd-MMM-yyyy

Please try the following code:

 

 

<%@ Page Language=”C#” %>

<%@ Register Assembly=”AjaxControlToolkit” Namespace=”AjaxControlToolkit” TagPrefix=”ajaxToolkit” %>

<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;

<script runat=“server”>

</script>

<html xmlns=http://www.w3.org/1999/xhtml&#8221;>
<head runat=“server”>
    <title></title>
</head>
<body>
    <form id=“form1” runat=“server”>
    <div>
    <div>
        <ajaxToolkit:ToolkitScriptManager ID=“ToolkitScriptManager1” runat=“server”>
        </ajaxToolkit:ToolkitScriptManager>
        <strong>Enter Date (format:dd-MMM-yyyy <em>dd-MMM-yyyy</em>):</strong>
        <br />
        <asp:TextBox ID=“TextBox2” runat=“server” ReadOnly=“false” />
        <ajaxToolkit:MaskedEditExtender ID=“MaskedEditExtender2” runat=“server” ClearMaskOnLostFocus=“false”
            MaskType=“none” Mask=“99-LLL-9999” TargetControlID=“TextBox2” Filtered=“-“ />
        <ajaxToolkit:MaskedEditValidator ID=“MaskedEditValidator2” runat=“server” ControlToValidate=“TextBox2”
            ControlExtender=“MaskedEditExtender2” EmptyValueMessage=“Start Date is Required”
            InvalidValueMessage=“Date is Invalid” IsValidEmpty=“False” TooltipMessage=“Input a Date”
            Enabled=“true” />
        <ajaxToolkit:CalendarExtender ID=“CalendarExtender3” runat=“server” TargetControlID=“TextBox2”
            Format=“dd-MMM-yyyy” PopupButtonID=“ImageButton2” />
    </div>
    </div>
    </form>
</body>
</html>

October 31, 2008 Posted by | ASP.NET AJAX | | Leave a comment

Make postback from ModalPopupExtender

To make a button which inside ModalPopup do a server-side onclick event, we should make sure the OkControlID of the ModalPopup is not the button we want to do a postback:

<%@ Page Language=”C#” %>
<%@ Register Assembly=”AjaxControlToolkit” Namespace=”AjaxControlToolkit” TagPrefix=”cc1″ %>
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”&gt;

<script runat=“server”>
protected void btn_OK_Click(object sender, EventArgs e)
{
Page.Title = “lance”;
}

</script>

<html xmlns=http://www.w3.org/1999/xhtml&#8221;>
<head runat=“server”>
<title></title>
</head>
<body>
<form id=“form1” runat=“server”>
<div>
<asp:LinkButton ID=“lnkbtn_comments” runat=“server”>LinkButton</asp:LinkButton>
<cc1:ToolkitScriptManager ID=“ToolkitScriptManager1” runat=“server”>
</cc1:ToolkitScriptManager>
<asp:Panel ID=“panel_Comment” runat=“server” Width=“300px” Height=“150px” CssClass=“modalPopup”>
<br />
<br />
<center>
<table>
<tr>
<td>
Title:
</td>
<td align=“left”>
<asp:TextBox ID=“txt_Title” runat=“server” />
</td>
</tr>
<tr>
<td>
Comment:
</td>
<td>
<asp:TextBox ID=“txt_Comment” runat=“server” TextMode=“MultiLine” />
</td>
</tr>
<tr>
<td>
<asp:Button ID=“btn_OK” runat=“server” Text=“Save” OnClick=“btn_OK_Click” />
</td>
<td align=“left”>
<asp:Button ID=“btn_Cancel” runat=“server” Text=“Cancel” />
</td>
</tr>
</table>
</center>
</asp:Panel>
<cc1:ModalPopupExtender ID=“panel_Comment_ModalPopupExtender” runat=“server” TargetControlID=“lnkbtn_comments”
PopupControlID=“panel_Comment” DropShadow=“true” BackgroundCssClass=“modalBackground”
CancelControlID=“btn_Cancel”>
</cc1:ModalPopupExtender>
</div>
</form>
</body>
</html>

October 31, 2008 Posted by | ASP.NET AJAX | | 1 Comment