I have an user control in AJAX for the date calendar and I want to disable the future dates in the Calendar. I have tried to do it by using the Maximum Value property but that doesn't disables the control.
Any suggestions or help?
<%# Control Language="C#" AutoEventWireup="true" CodeFile="usrCtrlDatePicker.ascx.cs" Inherits="UserControls_usrCtrlDatePicker" %>
<table cellspacing="0" cellpadding="0" border="0" style="height:18px;">
<tr>
<td style="text-align:center; vertical-align:middle; height:16px">
<asp:TextBox ID="txtDateEntry" runat="server" Width="75px" MaxLength="1" style="text-align:justify"/>
<img alt="" id="btnShowCalendar" runat="server" src="../images/calendar.gif" style="margin-left:-4px; margin-bottom:-3px; height:17px; width:17px;" />
<ajax:MaskedEditExtender ID="meeDateEntry" runat="server"
TargetControlID="txtDateEntry"
Mask="99/99/9999"
MessageValidatorTip="false"
CultureName="en-US"
OnFocusCssClass="MaskedEditFocus"
OnInvalidCssClass="MaskedEditError"
MaskType="Date"
ErrorTooltipEnabled="false" />
<ajax:MaskedEditValidator ID="mevDateEntry" runat="server" ControlExtender="meeDateEntry" ControlToValidate="txtDateEntry" Display="Dynamic" EmptyValueBlurredText="*" EmptyValueMessage="Date is required" InvalidValueBlurredMessage="*" InvalidValueMessage="Date is invalid" IsValidEmpty="false" MaximumValueBlurredMessage="sjdfhsdfh" MaximumValueMessage="Maximum Value Exceeded." TooltipMessage="" ValidationExpression="(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](19|20)\d\d" ValidationGroup="" />
<ajax:CalendarExtender ID="ceDateEntry" runat="server"
Format="MM/dd/yyyy"
TargetControlID="txtDateEntry"
PopupButtonID="btnShowCalendar" />
</td>
</tr>
</table>
You can use OnClientDateSelectionChanged event. Refer this.
I want to disable the future dates in the Asp.net ajax calendar extender
By setting the EndDate property of calendar extender you can achieve this required functionality or by using css class. css class technique is given below in the second link
For reference please check the following links, In the second link it uses css class to disable future dates.
Disable Future and Past Date
Disable Future Dates in ASP.Net AJAX
Related
I have this code in my page that that has required field validation in the textboxes. The other controls are working fine(I have not included the other controls because its confusing) except for this radcaptcha. I have included it in the validation group but it is still not being displayed in the validation summary when it pops up. Thanks in advance.
<table>
<tr>
<td>
<asp:ValidationSummary ID="vs1" runat="server" BorderStyle="Solid" BorderWidth="1px"
Width="100%" Style="border-color: Black" BackColor="White" ForeColor="Red"
ValidationGroup="Group"></asp:ValidationSummary>
</td>
</tr>
<tr>
<td>
<div class="divContainer">
<telerik:RadCaptcha ID="RadCaptcha1" runat="server" ValidationGroup="Group" EnableRefreshImage="True" Display="Static" CssClass="CaptchaCss" Height="155px" Width="254px" CaptchaAudioLinkButtonText="" CaptchaLinkButtonText="" CaptchaImage-ImageCssClass="CaptchaImageCss" CaptchaImage-Width="231" CaptchaImage-Height="70" CaptchaTextBoxCssClass="rcTextBoxClass" CaptchaImage-EnableCaptchaAudio="True" CaptchaTextBoxLabelCssClass="rcLabelClass" ForeColor="#FFDC72" ErrorMessage="Invalid input"></telerik:RadCaptcha>
</div>
</td>
</tr>
</table>
Note that RadCaptcha performs the validation on the server, while the standard ASP.NET validation controls have client-side validation, which kicks in first, enabled by default. The client-side validation of all control in the validation group has to be disabled so that the error message of the captcha appears with the rest. You can check this in the link above.
Refer following link:
http://demos.telerik.com/aspnet-ajax/captcha/examples/validationsummary/defaultcs.aspx
You should use validationGroup property.
I am completely new to Ajax and have had no training. I'm just copying a co-worker's code. We have a page with two Ajax controls: one my co-worker wrote and one I wrote. Everything is working fine except for one item, and my co-worker's up to his eyeballs in another project, so I need to figure this out. The problem is that the Ajax control I wrote pops up a ListBox with two buttons: Close and Select. The Select button has an OnClick event and causes a postback, as is expected. However, the Close button does not have an OnClick event and still causes a postback. This is not the case with a very similar Ajax control that my co-worker wrote that sits on the same page. The code is below. My co-worker's code involves the Email Template; mine involves the Email(s) Lookup. For the life of me, I don't see any difference. Can anyone tell me why my Close button causes a PostBack and my co-worker's doesn't?
<!--my co-worker's control-->
<tr>
<td width="20%"><br /><div class="formtext">Email Template:</div></td>
<td colspan="3"><br />
<asp:Button ID="btn_ShowTemplate" runat="server"
Text="View/Edit Template" />
<ajax:ModalPopupExtender ID="mpTemplate" runat="server" PopupControlID="panelTemplate" TargetControlID="btn_ShowTemplate"
CancelControlID="BtnTemplateClose" BackgroundCssClass="modalBackground">
</ajax:ModalPopupExtender>
<asp:Panel ID="panelTemplate" runat="server" CssClass="modalPopupTemplate" align="center">
<div class="formtext_modal">Litigation Hold Email Template <img src="images/v2/modal_email.png" alt="Email" /><br /></div>
<cc1:Editor ID="TemplateEditor" runat="server" Width="675px" Height="400px" />
<br />
<asp:Button ID="BtnTemplateClose" runat="server" Text="Close" CssClass="btnMatterClose" />
<asp:Button ID="btnTemplateSave" runat="server" Text="Save" CssClass="btnMatterSelect" OnClick="btnTemplateSave_Click" />
</asp:Panel></td>
</tr>
<!--my control-->
<tr>
<!-- email cc section -->
<td>Email CC:<br /></td>
<td colspan="3"><asp:Button ID="btnEmails" runat="server" Text="Lookup Email" /> <asp:TextBox
ID="tbEmails" runat="server" Width="80%" ReadOnly="true"></asp:TextBox><br />
<ajax:ModalPopupExtender ID="mpEmails" runat="server" PopupControlID="panelEmails" TargetControlID="btnEmails"
CancelControlID="btnClose" BackgroundCssClass="modalBackground">
</ajax:ModalPopupExtender>
<asp:Panel ID="panelEmails" runat="server" CssClass="modalPopupAttorneys" align="center">
<table align="center" width="100%">
<tr>
<td>
<div class="formtext_modal">Email(s) Lookup <img src="images/v2/modal_search.png" alt="Search" /></div><br />
<asp:Label ID="Label3" runat="server" Width="600px" CssClass="formtext"
Text="Add Employees to Email CC line"></asp:Label>
<div style="BORDER: thin solid; OVERFLOW: auto; WIDTH: 600px; HEIGHT: 140px">
<asp:CheckBoxList ID="cblEmails" runat="server" Width="600px" Height="140px" SelectionMode="Multiple">
</asp:CheckBoxList>
</div>
</td>
</tr>
Server side buttons always cause a post back. One way to get around it is to add a client click function that returns false.
OnClientClick="return false;"
Edit
Your co-worker has defined the CancelControlID="BtnTemplateClose" on the ModalPopupExtender. That is what is repressing the post back. You also have the CancelControlID defined, but I can't find the close button (btnClose) anywhere in the code you have posted. Where are the close buttons in your control? If you make sure your close button has the ID btnClose, it would most likely work like your co-worker's close button.
Afternoon All,
I am using a visual studio 2010. I have a web page which is used to record minutes of meetings. The page has a section that the user can use to add 'Actions' to the site. I can get a user to successfully add an action to the page.
The issue that i have is i also have a grid view on the webpage and would like this to refresh once the user has added the new 'Action' to the page. So that the user can see that its been submitted.
Im new ish to the .net environment and VB and im not sure 100% how to complete this task.
I have the following code from my .aspx page....
Submitted Actions:
<hr />
<!-- DataSource for submitted Actions -->
<asp:SqlDataSource ID="OutstandingActionsDS" runat="server"
ConnectionString="<%$ ConnectionStrings:SMCConnectionString %>"
SelectCommand="Populate_grdOutstandingActions"
SelectCommandType="StoredProcedure"></asp:SqlDataSource>
<!-- Gridview that holds submitted Actions -->
<asp:GridView ID="GridView1" runat="server" DataSourceID="OutstandingActionsDS">
</asp:GridView>
<br />
<br />
New Actions to Record:
<hr />
<!-- Add new Action -->
<asp:Panel ID="pnlHeaderAction" runat="server" CssClass="pnl" Width="740px">
<div style="float:left;">
Record New Actions
</div>
<div style="float:right;">
<asp:Label ID="lblShowHideAction" runat="server" ></asp:Label>
</div>
<div style="clear:both"></div>
</asp:Panel>
<asp:Panel ID="pnlInfoAction" runat="server" CssClass="pnlBody">
<table>
<tr>
<td style="width:498px; height: 15px;"><h5>Actions:</h5></td>
<td style="width:130px; height: 15px;"><h5>Owner:</h5></td>
<td style="height: 15px;"><h5> Target Date:</h5></td>
</tr>
</table>
<table style="width: 99%">
<tr>
<td style="width: 495px">
<asp:TextBox ID="txtAction" runat="server" TextMode="MultiLine"
Width="493px" Height="50px" style="font-family:Verdana"></asp:TextBox>
</td>
<td style="width: 132px" valign="top">
<asp:TextBox ID="txtOwner" runat="server" Height="50px"
width="128px" style="font-family:Verdana"></asp:TextBox>
</td>
<td valign="top">
<asp:TextBox ID="txtTargetDate" runat="server" width="89px" style="font-family:Verdana"></asp:TextBox>
</td>
</tr>
</table>
<br />
<div style="text-align: right;">
<asp:Button ID="btnAddAction" runat="server" Text="Add New Action" CssClass="button" />
</div>
</asp:Panel>
Here is my code for the VB page...
Protected Sub btnAddAction_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnAddAction.Click
Dim oActionClass As New ActionClass
With oActionClass
.Action = txtAction.Text
.Owner = txtOwner.Text
.TargetDate = New SmartDate(Convert.ToDateTime(txtTargetDate.Text))
oActionClass.ActionID = ActionClassDAL.AddActionClass(oActionClass)
ClearActions()
End With
End Sub
Private Sub ClearActions()
txtAction.Text = ""
txtOwner.Text = ""
txtTargetDate.Text = ""
End Sub
This seems like a simple request but i cant seem to find anything that shows me how to refresh the grid based on the user adding the action to the system.
Many thanks in advance for any help offered.
Regards
Betty
you just have to put a databind to the GridView1. I think is something like this:
me.GridView1.databind();
On the bottom of your method btnAddAction_Click.
I hope I have been helpful.
I have a basic form on my page with the following textbox and validator. When the validator is visible, there is a background image that is displayed. I would also like to be able to change the border of the textbox. Is that possible? If not in the ascx file, would it be possible in Javascript?
<tr>
<td class="FormLabel">First name*</td>
<td class="FormInput">
<asp:TextBox ID="txtFirstname" runat="server" Width="180" MaxLength="30" fieldname="FIRSTNAME" tablename="TblName"></asp:TextBox></td>
<td class="FormValidation">
<asp:RequiredFieldValidator ID="valFirstname" runat="server" ControlToValidate="txtFirstname" CssClass="ValidatorError"> </asp:RequiredFieldValidator></td>
</tr>
Thanks
If you would use a ValidatorCalloutExtender of the ASP.NET-Ajax-Control-Toolkit, this would be simple by applying an appropriate HighlightCssClass.
I am using validation summary control to display error messages of asp.net validation controls.
There are some validations in page for which validation controls are not being used. I am using custom javascript and jquery code for these. Kindly guide how I can display messages of these errors in validation summary control along with asp.net validation controls.
The key is to use the Custom Validation control. This control supports client side scripting (so you can still use your javascript code to do it) but still ties into the validation framework asp.net provides.
From the microsoft article, something like this:
<SCRIPT LANGUAGE="JavaScript">
function validateLength(oSrc, args){
args.IsValid = (args.Value.length >= 8);
}
</SCRIPT>
<asp:Textbox id="text1" runat="server" text="">
</asp:Textbox>
<asp:CustomValidator id="CustomValidator1" runat=server
ControlToValidate = "text1"
ErrorMessage = "You must enter at least 8 characters!"
ClientValidationFunction="validateLength" >
</asp:CustomValidator>
As Patrick said you can add the custom validator controls in place of your custom javascript/jQuery code. And then accordingly you can add the summary validation control. Also you can change the error message in your javascript code. Please check the below code for your reference.
<script type="text/javascript">
function validatetxtLength(source, args)
{
var txtVal=document.getElementById('<%=txtusername.ClientID %>').value;
if(txtVal=="")
{
document.getElementById('<%=custxtValidator.ClientID %>').setAttribute("errormessage","Please Enter the User Name");
args.IsValid=false;
}
else if(txtVal.length>9)
{
document.getElementById('<%=custxtValidator.ClientID %>').setAttribute("errormessage","Username must have less than 10 characters");
args.IsValid=false;
}
else
{
args.IsValid=true;
}
return;
}
</script>
<div>
<table cellpadding="0" cellspacing="0" border="0" width="712px">
<tr>
<td colspan="3" align="center">
Validator Testing
</td>
</tr>
<tr>
<td>
Please Enter your User Name:
</td>
<td>
<asp:TextBox ID="txtusername" runat="server" Width="150px"></asp:TextBox>
</td>
<td>
<asp:CustomValidator ID="custxtValidator" runat="server" ErrorMessage="User Name must have less than 10 characters"
Text="*" ForeColor="Red" ClientValidationFunction="validatetxtLength"></asp:CustomValidator>
</td>
</tr>
<tr>
<td colspan="3" align="center">
<asp:Button ID="btnsubmit" runat="server" Text="Submit" />
</td>
</tr>
</table>
<asp:ValidationSummary ID="ValidationSummary1" HeaderText="Please check below validations:"
runat="server" DisplayMode="BulletList" EnableClientScript="true" />
</div>
This might be useful for you.