Setting Page.IsValid to False
I've got an ASP user control which is basically using jquery UI datepicker just we'd have a standard calendar throughout our site.
I am trying to create a validation for this control so I would not have to create the validation in every page using the calendar. Is it possible to set the Page_IsValid to false from the ascx?
Here's the code:
<%@ Control Language="VB" AutoEventWireup="false" CodeFile="jQueryCalendar.ascx.vb" Inherits="Controls_Misc_jQueryCalendar" %>
<style type="text/css">
div.ui-datepicker, div.ui-widget {
font-size: 12px !important;
}
img.ui-datepicker-trigger{
margin-bottom:-5px;
}
</style>
<script type="text/javascript">
$(document).ready(function () {
$('.datepicker').datepicker({
showOn: 'button',
buttonImage: '<%= Me.ImageURL%>',
buttonImageOnly: true,
changeMonth: true,
changeYear: true,
showOtherMonths: true,
sele开发者_Python百科ctOtherMonths: true,
dateFormat: 'dd/mm/yy'
});
});
</script>
The IsValid
property is read-only and therefore cannot be set. Add a validator-control to your user control!
I see your user control does not contain the text-input for the datepicker at the moment, but instead adds the datepicker to all items of the class datepicker
. I suggest you change this so you have the TextBox
inside the usercontrol, this way you can put a validator control on it.
精彩评论