<asp:TextBox ID="f5" runat="server" CssClass="location" value="" placeholder="Enter Email ID:"
name="location"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ValidationGroup="rqrd" ControlToValidate="f5"
ErrorMessage="Required Field cannot be empty"></asp:RequiredFieldValidator>
<asp:RegularExpressionValidator ID="RegularExpressionValidator1" runat="server" ValidationGroup="rqrd" ValidationExpression="^[_a-z0-9-]+(\.[_a-z0-9-]+)*#[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,4})$" ControlToValidate="f5" ErrorMessage="Invalid Email-id"></asp:RegularExpressionValidator>
<asp:ScriptManager ID="scriptmanager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="PnlUsrDetails" runat="server">
<ContentTemplate>
<div class="location-block">
<div class="form-block location">
Username:</div>`enter code here`
<div class="form-block airport_codes">
</div>
<asp:TextBox ID="f6" runat="server" CssClass="location" AutoPostBack="true" OnTextChanged="f6_TextChanged" value="" placeholder="Enter Username:"
name="location">
</asp:TextBox>
<div id="checkusername" runat="server" Visible="false">
<asp:Label ID="lblStatus" runat="server"></asp:Label>
</div>
</div>
</ContentTemplate>
</asp:UpdatePanel>
This is my code the update panel part works perfectly but the other validators have stopped working
p.s. i use visual studio 2012 and i installed ajax control toolkit yesterday only from the manage nuGet packages ...
Thanking You in Advance
Put the ScriptManager above the TextBox and the RequiredFieldValidator.
the script manager tag actually asynchronously loads a part of the page but does not reload the java scripts (and thus the required field validators) associated with it. and thus it won't work. So avoid using script manager of c#.net. use normal ajax and jquery functions
Related
I have a very simple form that I am using in a web forms website. The form is embedded in an ascx control and it is re-used throughout the site in various pages. It was working fine until we decided to implement server-side validation using an ajax postback. So, I added update panels and triggers and everything works fine if I use the form from my Default.aspx form, but it doesn't work from any other page. I have been googling this for two days and so far I cannot figure out if this is an ASPX problem, or if it is an IIS configuration problem. I am very much stuck.
This is the form ( it is incredibly simple ). The form resides in an ASCX user control
<asp:UpdatePanel ID="AllFormFields" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div>
<asp:TextBox ID="txtFirstName" runat="server" placeholder="First Name"></asp:TextBox>
</div>
<div>
<asp:TextBox ID="txtLastName" runat="server" placeholder="Last Name"></asp:TextBox>
</div>
<div>
<asp:TextBox ID="txtEmail" runat="server" placeholder="E-Mail" TextMode="Email"></asp:TextBox>
</div>
<div>
<asp:TextBox ID="txtPhone" runat="server" placeholder="Phone" TextMode="Phone"></asp:TextBox>
</div>
<div>
<asp:DropDownList ID="rcbPrimarySpecialty" runat="server" EmptyMessage="Primary Specialty"></asp:DropDownList>
</div>
<div>
<asp:TextBox ID="txtComments" Rows="10" TextMode="MultiLine" runat="server" placeholder="Comments"></asp:TextBox>
</div>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
<div>
<asp:Button ID="btnSubmit" runat="server" Text="Request Info" CausesValidation="true" ClientIDMode="AutoID" />
</div>
<div>
<asp:UpdatePanel ID="ValidationMessagePanel" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:Label ID="lblValidationMessage" runat="server" Text=""></asp:Label>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnSubmit" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
The idea is that the user clicks the button btnSubmit and ajax calls its click handler.
When I use the site under my VS debugger, the click handler is not even called. Something else is interfering with the Ajax call and the postback never happens.
I'm new to this site and asp.net (I'm coming from a classic asp background). I'm hoping someone could help me add a paging function to a repeater? I've tried following some other tutorials I've found but i keep hitting a brick wall. Here's my code:
<form runat="server">
<asp:Repeater ID="Repeater1" runat="server" DataSourceID="SqlDataSource1">
<ItemTemplate>
<div class="middlebar"><!--middlebar -->
<div class="middlebartext"><!--middlebartext -->
<small><asp:Label runat="server" ID="Label5"text='<%# Eval("PMonthName")%>' /><br /><asp:Label runat="server" ID="Label6" text='<%# Eval("PDay")%>' /></small>
</div><!--middlebartext -->
<div class="middlebarcorner"><img src="Images/cornermiddle.png" alt="Corner Ribbon Image" /></div><!--middlebarcorner -->
<div class="middlebartexttitle"><asp:Label runat="server" ID="Label3"
text='<%# Eval("Header")%>' /><br />
<div class="middletextauth">Added By: <asp:Label runat="server" ID="Label2"
text='<%# Eval("AddedBy")%>' /></div><!--middletextauth -->
<div class="middletextkw">Keywords: <span class="grey">key, words, test, file</span></div><!--middletextkw -->
</div><!--middlebartexttitle -->
</div><!--middlebar -->
<br />
<asp:Label runat="server" ID="Label4"
text='<%# Eval("PContent")%>' />
<div class="ruler"></div>
</ItemTemplate>
</asp:Repeater>
</form>
<asp:SqlDataSource
ConnectionString=
"<%$ ConnectionStrings:Conn %>"
ID="SqlDataSource1" runat="server"
SelectCommand="SELECT * from DBNAME where Deleted = 'False' Order By DateAdded DESC">
</asp:SqlDataSource>
please check below links and let me know if this helps you
http://www.dotnetcurry.com/ShowArticle.aspx?ID=345
http://www.codeproject.com/Articles/31819/Pagination-with-Repeater-Control
Kindly check out these tutorials ::
Pagination-with-Repeater-Control
Custom Paging with the ASP.NET Repeater Control
paging-repeater
paging-with-an-asp-net-repeater
For all those like me who are trying to make a repeater for a list of date, may i suggest using a listview instead. With a list view you can use data paging function within visual studio. I followed this tutorial and found it very helpful:
Using ASP.NET 3.5's ListView and DataPager Controls
This is my first question in stackoverflow.com.
I am working on a school project which I have to validate the input from the user. Everytime the page load, it give the server error message. Please see the codes, and the error message after.
<div>
<table>
<td>
<asp:RadioButton ID="RadioButton1" runat="server"></asp:RadioButton>
<asp:RequiredFieldValidator ID="validateCheck" runat="server" ControlToValidate="RadioButton1" ErrorMessage="Please Enter" Display="Dynamic"></asp:RequiredFieldValidator>
</td>
</table>
</div>
Server Error in '/' Application.
Control 'RadioButton1' referenced by the ControlToValidate property of 'validateCheck' cannot be validated.
The RequiredFieldValidator does not validate a RadioButton. However, you can use the RadioButtonList control instead (validated by RequiredFieldValidator).
The asp:RadioButton do not support validation, instead of RadioButton use a RadioButtonList:'
<form id="form1" runat="server">
<div>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ErrorMessage="RequiredFieldValidator" ControlToValidate="RadioButtonList1"></asp:RequiredFieldValidator>
</div>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
<asp:RadioButtonList ID="RadioButtonList1" runat="server">
<asp:ListItem>One</asp:ListItem>
<asp:ListItem>Two</asp:ListItem>
</asp:RadioButtonList>
</form>
I would like my login control to have a "Loading..." gif shown when a user logs in.
In order to have my login control display how I wanted, I converted it to a template. I then followed the guidance seen here: here and here to show the gif during a postback.
I'm having a couple of problems now though. When I try to sumbit an invalid login, the page does as it's supposed to: it shows the loading gif, and then the gif goes away after the login is determined invalid. But now even when I enter a valid login it says it's invalid. Did I mess something up when I edited the login template?
My other problem is that I have the "keepLogged" checkbox stylized. The style is being added by JQuery in the head. It shows it properly when you first go to the page, but after the postback, when the login is shown to be invalid, the style isn't applied and it's a normal checkbox.
Here's the code:
<script>
$(document).ready(function () {
$("input[type=checkbox]").addClass("mini-switch");
});
</script>
<form id="form1" runat="server" class="form with-margin" name="login-form">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="updateLogin" runat="server" DefaultButton="mainLogin$LoginButton">
<ContentTemplate>
<asp:Login ID="mainLogin" runat="server" RenderOuterTable="False" onloginerror="mainLogin_LoginError">
<LayoutTemplate>
<div class="block-header">Please login</div>
<asp:ValidationSummary ID="LoginUserValidationSummary" runat="server"
ValidationGroup="mainLogin" CssClass="message error no-margin"
DisplayMode="List"/>
<input type="hidden" name="a" id="a" value="send">
<p class="inline-small-label">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName"><span class="big">User name</span></asp:Label>
<asp:TextBox ID="UserName" runat="server" CssClass='full-width'></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server"
ControlToValidate="UserName" ErrorMessage="User Name is required."
ToolTip="User Name is required." ValidationGroup="mainLogin"
Display="None" />
</p>
<p class="inline-small-label">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password"><span class="big">Password</span></asp:Label>
<asp:TextBox ID="Password" runat="server" TextMode="Password" CssClass='full-width'></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server"
ControlToValidate="Password" ErrorMessage="Password is required."
ToolTip="Password is required." ValidationGroup="mainLogin"
Display="None" />
</p>
<asp:Button ID="LoginButton" runat="server" CommandName="Login"
Text="Log In" type="button"
ValidationGroup="mainLogin" onclick="LoginButton_Click" CSSClass='button float-right'/>
<p class="input-height">
<asp:CheckBox ID="keepLogged" runat="server" Checked="True"/>
<asp:Label ID="Label1" runat="server" Text="Keep me logged in" AssociatedControlID="keepLogged" CssClass="inline"></asp:Label>
</p>
</LayoutTemplate>
</asp:Login>
</ContentTemplate>
</asp:UpdatePanel>
</div>
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<img alt="" src="images/lock.gif" /> <strong>Logging In...</strong>
</ProgressTemplate>
</asp:UpdateProgress>
</form>
Thanks for any help.
I don't think that the built-in ASP.NET login control will work properly inside of an UpdatePanel. There are other ways to achieve the same effect, though. There's an article here that should get you started.
I have code like this on some aspx page in my Web Application:
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server"/>
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<div>
<asp:Label ID="lbl1" runat="server" Text="Laber1" />
<asp:Button ID="btn1" runat="server" Text="Button1" onclick="btn1_Click" />
</div>
</ContentTemplate>
</asp:UpdatePanel>
<!--
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"/>
<asp:TextBox ID="txtAjaxToolkit" runat="server" />
<asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtAjaxToolkit" />
-->
</asp:Content>
When I compile the project and go to this page in the browser, I get this exception:
[InvalidOperationException: На страницу можно добавить только один экземпляр ScriptManager.]
(translate: "There only one instance of ScriptManager allowed on this page").
Why do I get this message if second script manager (ToolkitScriptManager) is located in comments?
I am using ASP.NET 4 and ASP.NET Ajax Control Toolkit.
P.S: Sorry for my english.
Use server side comment syntax.
<%---
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"/>
<asp:TextBox ID="txtAjaxToolkit" runat="server" />
<asp:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtAjaxToolkit" />
---%>
You've used HTML comments, but the markup engine doesn't care about that - it'll still try to generate the content of that HTML comment. After all, you might want something like a timestamp in a comment.
You want a server-side comment, like this;
<%--
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"/>
<asp:TextBox ID="txtAjaxToolkit" runat="server" />
<asp:CalendarExtender ID="CalendarExtender1" runat="server"
TargetControlID="txtAjaxToolkit" />
--%>
It's all a matter of working out what's going to figure out that something is a comment - the HTML <!-- comment --> is aimed at a browser; the `<%-- comment --%> is aimed at the ASPX processor.