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.
Related
I'm using bootstrap to collapse and expand a table, which is working fine but I'm using classes instead of IDs. With this, expanding one row expands all the rows rather than just that one. My question is how does my data-target point at a nested repeater id? The transactionCollapse ID is unable to be targeted directly and I've tried doing <%=transactionGroupedList.FindControl("transactionCollapse")%> but it threw an error.
<tbody>
<asp:Repeater runat="server" ID="transactionGroupedList" OnItemDataBound="TransactionGroupedDataList_ItemDataBound">
<ItemTemplate>
<tr>
<!-- This line should target the transactionCollapse ID below instead of the class -->
<td data-toggle="collapse" data-target=".transactionCollapse">
<span id="transactionGroupCollapseIcon" runat="server" class="fonticon-down-arrow"></span>
<custom:Label runat="server" ID="transactionActivityDataColumnLabel"></custom:Label>
</td>
<td>
<custom:Label runat="server" ID="transactionDateDataColumnLabel">
</custom:Label>
</td>
<td>
<custom:Label runat="server" ID="transactionNumberDataColumnLabel">
</custom:Label>
</td>
<td>
<custom:Label runat="server" ID="transactionAmountDataColumnLabel">
</custom:Label>
</td>
<td>
<custom:Label runat="server" ID="transactionStatusDataColumnLabel">
</custom:Label>
</td>
</tr>
<asp:Repeater runat="server" ID="transactionDetailList" OnItemDataBound="TransactionDetailsDataList_ItemDataBound">
<ItemTemplate>
<tr id="transactionCollapse" runat="server" class="collapse transactionCollapse">
<td colspan="2">
<custom:Label runat="server" ID="transactionDetail">
</custom:Label>
</td>
<td>
<custom:Label runat="server" ID="transactionDetailTransactionNumber">
</custom:Label>
</td>
<td>
<custom:Label runat="server" ID="transactionDetailAmount">
</custom:Label>
</td>
</tr>
</ItemTemplate>
</asp:Repeater>
</ItemTemplate>
</asp:Repeater>
</tbody>
The Online Payment row is what collapses/expands the Posting - and MP Payment rows below. This user only has one Online Payment, but many users will have multiple.
You have a couple of problems. First of all when using FindControl inside a Repeater/GridView etc is index based. So you need to use FindControl on the correct Item.
transactionGroupedList[i].FindControl("transactionCollapse")
However the above will still not work because transactionCollapse is in a nested Repeater that needs to be found first and then access the correct Item Index.
transactionGroupedList.Items[0].FindControl("transactionDetailList").Items[0]...
But this will also not work since FindControl does not know that transactionDetailList is a Repeater with index based Items. So you need to cast the nested Repeater first before you can access it's items. So it becomes this
<%= ((Repeater)transactionGroupedList.Items[i].FindControl("transactionDetailList")).Items[i].FindControl("transactionCollapse").ClientID %>
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
In my masterpage I have links for users also the authorization is different like admin and regular user.
links under each other and I can hide the hyperlinks depending on authorization status but the problem is i.e when I have 3 links the second link for the admin the link will hide when the user is regular and the link place empty like 123 1 3.
So I have an idea using table each link in one tr but I can`t hide td or tr because Visible is not in properties.
any help?
thank you
According to how to hide a having asp.net control:
you can give ID either to the TD or TR to which you want to hide/show
with the runat="server" and also you can take that tr/td inside the
div tag and give id to that div tag and also runat=server attribute
and after that you can pro grammatically hide/show that div.
like
<pre>
<tr id="trhide" runat="server"> </tr>
</pre>
in code behind write
trhide.visible=true/false
In the master page VB code behind add a public procedure: Then call the public set from your aspx page.
'======================================================================================================
'Set Tab No invisible
'======================================================================================================
Public Sub setTabNumberLabel(visible As Int16)
If visible = 0 Then
td_page.Visible = False
Else
td_page.Visible = True
End If
End Sub
The master aspx would be:
<table style="width:100%">
<!--<tr style="background-color:#565656;">-->
<tr>
<td style="width:15%;text-align:left;vertical-align:bottom;padding-left:20px;">Stategic Energy Assessment ( <asp:Label ID="lbl_year_ended" runat="server" /> )</td>
<td style="text-align:center;vertical-align:bottom;"><asp:Label ID="lbl_utility_name_and_id" runat="server" /></td>
<td id="td_page" runat="server" style="width:15%;text-align:right;vertical-align:bottom;padding-right:20px;">Tab No: <asp:Label ID="lbl_page" runat="server" /></td>
</tr>
<tr><td colspan="3" style="vertical-align:central"><hr /></td></tr>
<tr>
<td style="width:15%;text-align:left;vertical-align:central">
<asp:Label ID="lbl_print_version" runat="server" Text="View Printable Vision" Visible="false" />
</td>
<td style="font-size:larger; font-weight:bold; text-align:center; text-transform:capitalize;vertical-align:central">
<asp:Label ID="lbl_schedule_name" runat="server" />
</td>
<td style="width:15%;text-align:right;vertical-align:central;padding-right:20px;">
<asp:LinkButton ID="btn_footnotes" runat="server" Visible="false">Footnotes</asp:LinkButton>
</td>
</tr>
<%--<tr><td colspan="3" style="vertical-align:central" class="auto-style1"></td></tr>--%>
<tr><td colspan="3" style="vertical-align:central; padding-right:20%;padding-left:20%; ">
<i><asp:Label ID="lbl_headnotes" runat="server" Text="" /></i></td></tr>
<tr><td colspan="3" style="vertical-align:central"><hr /></td></tr>
</table>
The other answer is correct and works fine. Just adding complete piece of code.
It's quite amusing that you don't need to add runat=server for a table but you can still hide tr for that table using runat attribute.
<table>
<tr>
<td>aa</td><td>bb</td>
</tr>
<tr id="trHide1" runat="server">
<td>aa</td><td>bb</td>
</tr>
<tr id="trHide2" runat="server">
<td>aa</td><td>bb</td>
</tr>
<tr>
<td>aa</td><td>bb</td>
</tr>
</table>
Now just set properties in codebehind (hiding the tr)
trHide1.Visible = false;
trHide2.Visible = false;
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.
At the moment I have something like this
<asp:Repeater ID="rptEventsList" DataSourceID="srcQuestionList" runat="server">
<ItemTemplate>
<td><span><%# Eval("orderBy").ToString()%>)</span></td>
<td><%# Eval("question").ToString()%></td>
<td><asp:RadioButton ID="RadioButton1" runat="server" /></td>
<td><input name="question<%# Eval("orderBy").ToString()%>" type="radio" id="True" value="True" class="styled" /></td>
<td><input name="question<%# Eval("orderBy").ToString()%>" type="radio" id="False" value="False" class="styled" /></td>
</tr>
</ItemTemplate>
</asp:Repeater>
And in the code behind I capture the values as Request.Form("question1") for example and this all works fine.
Now I am wondering how to add validation to this, I think I have to apply changes to a RadioButton control but I can't see how I could add my dynamic RadioButton names in there with my id from stored procedure.
Also I would like to add the validation to the top of the screen as a validation summary.
Look into Validation Server Controls.