Calender extender not working after removing and then adding ajax toolkit - asp.net

The below code was working fine and i accidentally deleted ajax toolkit and when i reconfigured it its nit showing calender on clicking over text box.please tell me what to do with it .
moreover i request you to reply soon
<%# Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/emp.Master" CodeBehind="empleaveapp.aspx.vb" Inherits="abc.WebForm10" %>
<%# Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
<head />.
<%--
<head id="Head2" runat="server" />.
--%>
<head />.
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Label ID="Label1" runat="server" Text="From"></asp:Label>
<asp:TextBox ID="calefrom" runat="server" CssClass="textbox" Height="16px"
Width="157px"></asp:TextBox>
<cc1:CalendarExtender ID="calefrom_CalendarExtender" runat="server"
Enabled="True" TargetControlID="calefrom" Format="yyyy-MM-dd">
</cc1:CalendarExtender>
<asp:CompareValidator ID="CompareValidator2" runat="server"
ControlToCompare="txttdate" ControlToValidate="calefrom" CssClass="active"
ErrorMessage="Please enter a day after today's date"
Operator="GreaterThan" > </asp:CompareValidator>
<br />
<asp:TextBox ID="txttdate" runat="server" Width="1px"></asp:TextBox>
<br />
<asp:Label ID="Label2" runat="server" Text="To"></asp:Label>
<asp:TextBox ID="caleto" runat="server" Height="20px" CssClass="textbox"></asp:TextBox>
<cc1:CalendarExtender ID="caleto_CalendarExtender" runat="server"
Enabled="True" TargetControlID="caleto" Format="yyyy-MM-dd">
</cc1:CalendarExtender>
<asp:CompareValidator ID="CompareValidator1" runat="server" Format="yyyy-MM-dd"
ControlToCompare="calefrom" ControlToValidate="caleto"
ErrorMessage="To date can not be smaller then from date"
Operator="GreaterThanEqual"></asp:CompareValidator>
<br />
<br />
<asp:Label ID="Label3" runat="server" Text="Reason"></asp:Label>
<asp:TextBox ID="txtreason" runat="server"
CssClass="textbox"></asp:TextBox>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
ControlToValidate="txtreason"
ErrorMessage="Reason is must for manager to know better"></asp:RequiredFieldValidator>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Send Request" />
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
<p>
</p>
</asp:Content>

It's your ScriptManager. It should be cc1:ToolkitScriptManager and not asp:ScriptManager. You need the toolkit's scripts for the extenders to work.

Related

ASP.net validation of any invalid value

<%# Page Language="C#" AutoEventWireup="true" CodeFile="Calculator.aspx.cs" Inherits="Calculator" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Stats Calculator</title>
<style>
body {
background-color: powderblue;
}
h4 {
font-weight: normal;
}
</style>
</head>
<body>
<h1>Statistics Calculator</h1>
<p>Enter three numbers and click the Submit button to find out the statistics</p>
<form id="form1" runat="server">
<div>
<b>
<asp:Label ID="FirstNumber" runat="server" Text="First Number: " AssociatedControlID="TextBox1"></asp:Label></b>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:RequiredFieldValidator ID="required1" runat="server" ControlToValidate="TextBox1" ForeColor="Red" ErrorMessage="*">
</asp:RequiredFieldValidator>
<br />
<br />
<asp:RegularExpressionValidator
ID="regex1"
ControlToValidate="TextBox1"
ValidationExpression="((\d+)((\.\d{1,2})?))$"
ErrorMessage="Input string is not in correct format"
Text="Input string is not in correct format"
ForeColor="Red"
runat="server">
</asp:RegularExpressionValidator>
<br />
<b>
<asp:Label ID="SecondNumber" runat="server" Text="Second Number: " AssociatedControlID="TextBox2"></asp:Label></b>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator ID="required2" runat="server" ControlToValidate="TextBox2" ForeColor="Red" ErrorMessage="*">
</asp:RequiredFieldValidator>
<br />
<br />
<asp:RegularExpressionValidator
ID="regex2"
ControlToValidate="TextBox2"
ValidationExpression="((\d+)((\.\d{1,2})?))$"
ErrorMessage="Input is not in correct format"
Text="Input string is not in correct format"
ForeColor="Red"
runat="server">
</asp:RegularExpressionValidator>
<br />
<b>
<asp:Label ID="ThirdNumber" runat="server" Text="Third Number: " AssociatedControlID="TextBox3"></asp:Label></b>
<asp:TextBox ID="TextBox3" runat="server"></asp:TextBox><asp:RequiredFieldValidator ID="required3" runat="server" ControlToValidate="TextBox3" ForeColor="Red" ErrorMessage="*">
</asp:RequiredFieldValidator>
<br />
<br />
<asp:RegularExpressionValidator
ID="regex3"
ControlToValidate="TextBox3"
ValidationExpression="((\d+)((\.\d{1,2})?))$"
ErrorMessage="Input is not in correct format"
Text="Input string is not in correct format"
ForeColor="Red"
runat="server">
</asp:RegularExpressionValidator>
<br />
<br />
<asp:Button ID="btnSubmit" runat="server" OnClick="submit" Text="Submit" />
<h1>&nbsp&nbsp&nbsp Statistics of the numbers you entered</h1>
<h4>&nbsp&nbsp&nbsp <b>Maximum:</b>&nbsp<asp:Label ID="Label4" runat="server"></asp:Label></h4>
<h4>&nbsp&nbsp&nbsp<b>Minimum:</b>&nbsp<asp:Label ID="Label3" runat="server"></asp:Label></h4>
<h4>&nbsp&nbsp&nbsp <b>Average:</b>&nbsp<asp:Label ID="Label2" runat="server"></asp:Label></h4>
<h4>&nbsp&nbsp&nbsp <b>Total:</b>&nbsp<asp:Label ID="Label1" runat="server"></asp:Label></h4>
</div>
</form>
</body>
</html>
Here I have an ASP.net form with validation, althought I would like to know how I would be able to display an error message for all fields if any of the values are not valid. What would be the best way to do this ?

ModalPopupExtender only pops up the UpdatePanel once

The ModalPopupExtender wires the btnCancel button to trigger the a popup an UpdatePanel. The UpdatePanel is a cancel confirmation which contains a Yes button and a No button. After clicking the No button, the panel is closed but the btnCancel no longer trigger the popup when being clicked again. The Yes button works and triggers the server side YesButton_Click event. Here is my code. Thanks for your help.
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<cc1:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" />
<asp:Button ID="btnCancel" Text="Cancel Task" runat="server" ToolTip="Cancel the displayed task and remove it from Tracker" CausesValidation="false" />
<cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnCancel"
PopupControlID="ConfirmationPanel" BackgroundCssClass="modalBackground" />
<asp:UpdatePanel ID="upd_yes_no" runat="server">
<ContentTemplate>
<asp:Panel ID="ConfirmationPanel" runat="server" CssClass="modalPopup" Style="display: none">
<div class="modalPopup-text">
Are you sure you want to cancel this task?<br />
<br />
<asp:Button ID="YesButton" runat="server" Text="Yes" CommandArgument="Yes" OnClick="YesButton_Click" />
<asp:Button ID="NoButton" runat="server" Text="No" CommandArgument="No" />
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
I'm not 100% positive but it appears that Extender and Extended controls must reside in the same UpdatePanel. So if you move your Cancel button and ModalPopupExtender control inside the UpdatePanel, it should work as expected.
<ajax:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" />
<asp:UpdatePanel ID="upd_yes_no" runat="server">
<ContentTemplate>
<span id="buttons">
<asp:Button ID="btnUndo" Text="Undo Edit" CommandArgument="undo" runat="server"
OnClick="undo" CausesValidation="false" />
<asp:Button ID="btnNewTask" Text="New Task" CommandArgument="newTask" runat="server"
ToolTip="Unchange current and create new task"
OnClick="NewTask" CausesValidation="false" />
<asp:Button ID="btnCancel" Text="Cancel Task" runat="server"
ToolTip="Cancel the displayed task and remove it from Tracker" CausesValidation="false" />
</span>
<ajax:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="btnCancel" PopupControlID="ConfirmationPanel" BackgroundCssClass="modalBackground" />
<asp:Panel ID="ConfirmationPanel" runat="server" CssClass="modalPopup" Style="display: none">
<div class="modalPopup-text">
Are you sure you want to cancel this task?
<br />
<br />
<asp:Button ID="YesButton" runat="server" Text="Yes" CommandArgument="Yes" OnClick="YesButton_Click" />
<asp:Button ID="NoButton" runat="server" Text="No" CommandArgument="No" />
</div>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>

File upload for Dynamic Data

I have the following code
<asp:Content ID="headContent" ContentPlaceHolderID="head" runat="Server">
</asp:Content>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" runat="Server">
<asp:DynamicDataManager ID="DynamicDataManager1" runat="server" AutoLoadForeignKeys="true">
<DataControls>
<asp:DataControlReference ControlID="FormView1" />
</DataControls>
</asp:DynamicDataManager>
<h2 class="DDSubHeader">
Edit entry from table
<%= table.DisplayName %></h2>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" EnableClientScript="true"
HeaderText="List of validation errors" CssClass="DDValidator" />
<asp:DynamicValidator runat="server" ID="DetailsViewValidator" ControlToValidate="FormView1"
Display="None" CssClass="DDValidator" />
<asp:FormView runat="server" ID="FormView1" DataSourceID="DetailsDataSource" DefaultMode="Edit"
OnItemCommand="FormView1_ItemCommand" OnItemUpdated="FormView1_ItemUpdated" RenderOuterTable="false"
OnPageIndexChanging="FormView1_PageIndexChanging">
<EditItemTemplate>
<table id="detailsTable" class="DDDetailsTable" cellpadding="6">
<asp:DynamicEntity runat="server" Mode="Edit" />
<tr class="td">
<td colspan="2">
<asp:LinkButton runat="server" CommandName="Update" Text="Update" />
<asp:LinkButton runat="server" CommandName="Cancel" Text="Cancel" CausesValidation="false" />
<br />
</td>
<td>
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Label ID="lblMessage" runat="server">
</asp:Label>
<asp:Button ID="btnUpload" runat="server" OnClick="btnUpload_Click" Text="Upload" />
</td>
</tr>
</table>
</EditItemTemplate>
<EmptyDataTemplate>
<div class="DDNoItem">
No such item.</div>
</EmptyDataTemplate>
</asp:FormView>
<asp:LinqDataSource ID="DetailsDataSource" runat="server" EnableUpdate="true" />
<asp:QueryExtender TargetControlID="DetailsDataSource" ID="DetailsQueryExtender"
runat="server">
<asp:DynamicRouteExpression />
</asp:QueryExtender>
</ContentTemplate>
</asp:UpdatePanel>
This file was generate using Dynamic Data. I am trying to add a file upload control in the form but in the code behind I can't acces 'FileUpload1' to see if it contains elements.
How can I do that?
If I make a new form it works but I can't get it out to work in my existing form.
<form id="form1" runat="server"></form>
It's common issue.
You are trying to upload file on ajax request calling upload from update panel.
But you need full postback to upload it using serious FileUpload or look for javascript based file upload controls.

ASP.NET Panel Not Ending

I have created an ASP.NET page with an AJAX Accordion control. Within on the panes are several controls, some of which I've placed inside a Panel control, for various reasons.
However, controls which are on the page AFTER the closing tag for the panel are appearing INSIDE the panel when the page is rendered. For the life me I can't figure out why, and it's driving me crazy! Even clicking on the header of the Accordion Pane after the one containing the panel doesn't cause the Pane to expand, which it did before I added the Panel, seemingly because even IT is behaving as if it's within the Panel!
Any ideas what I'm doing wrong? How can I make the page believe that the panel ends!!?
<asp:Accordion ID="accQuestionnaire" runat="server" RequireOpenedPane="false" ContentCssClass="AccordionContent" HeaderCssClass="AccordionHeader" FadeTransitions="true"
transitionduration="250" HeaderSelectedCssClass="AccordionSelected" SelectedIndex="0" SuppressHeaderPostbacks="true" >
<Panes>
<%--START OF Tristan Link Pane (0)-------------------------------------------------------------%>
<asp:AccordionPane ID="pnTristanLink" runat="server" ContentCssClass="AccordionContent" ViewStateMode="Enabled" >
<Header>
Tristan Link
</Header>
<Content>
<div class="centrebuttonsdiv" >
<asp:Button ID="btnSearchTristan" runat="server" CssClass="largebutton" Text="Search Tristan" /><br />
</div>
<asp:Panel ID="pnlTristanSearch" runat="server" CssClass="panel" >
<div class="leftdiv"> <%--Matching Tristan results--%>
<asp:FormView ID="fvTristanSearch" runat="server" CssClass="FormView" >
<ItemTemplate>
<asp:Label ID="lblTristanSearchLabel" runat="server" CssClass="fieldtitle" Text="The information from Tristan for this Case Number is:" /><br /><br />
<asp:Label ID="lblAnimalNameLabel" runat="server" CssClass="fieldtitle" Text="Horse Name: " />
<asp:Label ID="lblAnimalName" runat="server" Text='<%# Eval("PetName") & " " & Eval("ClientNameLast") %>' /><br />
<asp:Label ID="lblGenderLabel" runat="server" CssClass="fieldtitle" Text="Sex: " />
<asp:Label ID="lblGender" runat="server" Text='<%# Eval("L_GenderDesc") %>' /><br />
<asp:Label ID="lblBreedLabel" runat="server" CssClass="fieldtitle" Text="Breed: " />
<asp:Label ID="lblBreed" runat="server" Text='<%# Eval("L_BreedDesc") %>' /><br />
<asp:Label ID="lblDOBLabel" runat="server" CssClass="fieldtitle" Text="DOB: " />
<asp:Label ID="lblDOB" runat="server" Text='<%# Eval("PetDOB", "{0:d}") %>' /><br /><br />
</ItemTemplate>
</asp:FormView>
</div>
<div class="rightdiv">
<br /><br />
<asp:Label ID="lblUnmatchedAppointments" runat="server" Text="Appointments for this horse with no Colic Study details:" Visible="false" /><br />
<asp:ListBox ID="lstUnmatchedAppointments" runat="server" DataSourceID="SQLUnmatchedAppointments" DataTextField="AppointmentDate" DataTextFormatString="{0:d}" DataValueField="AppointmentID"
Visible = "False" />
</div>
<div class="cleardiv" />
</asp:Panel>
<div class="centrebuttonsdiv" >
<asp:Label ID="lblTristanSearchInstructions" runat="server" Text="Select an appointment from the list above and click 'Save Section' to continue. Otherwise, click 'Clear Retrieved Information'
to search again" Visible="false" /><br />
<asp:Button ID="btnClearTristanSearch" runat="server" Text="Clear Retrieved Information" Visible="false" CssClass="largebutton" />
<asp:Button ID="btnSaveTristanLink" runat="server" Text="Save Section" OnClientClick="disablePanes()" Visible="false" Enabled="false" CssClass="largebutton" />
</div>
</Content>
</asp:AccordionPane>
I believe that changing this line:
<div class="cleardiv" />
to this
<div class="cleardiv"></div>
will solve that rendering problem; <div> is not typically a self-closing tag.

Button refuses to work

I have a standard button which should call a method but it just refuses to work and I can't figure out why.
ASP code:
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button
ID="UploadButton" runat="server" onclick="UploadButton_Click" Text="Change Logo" />
Code behind:
protected void UploadButton_Click(object sender, EventArgs e)
{
PasswordLabel.Visible = true;
PasswordLabel.Text = "TEST Before";
Image_Inserting(this);
PasswordLabel.Text = "TEST After";
}
I just added the textbox methods to test it but it doesn't seem to be posting back (even when I remove Image_Inserting call). All other buttons work fine so I don't know why this one won't work.
EDIT: Whole page- Button code towards the bottom
<%# Page Title="" Language="C#" MasterPageFile="~/Standardmaster.Master" AutoEventWireup="true" CodeBehind="VendorAccount.aspx.cs" Inherits="PetShopParadise.Vendor_Pages.VendorAccount" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
<style type="text/css">
.style10
{
color: #FF0000;
}
</style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="mainContent" runat="server">
<h2>Account Details</h2>
<div id="RegistrationDiv">
<asp:FormView ID="FormView1" runat="server" DataSourceID="SqlDataSource1">
<EditItemTemplate>
Name:
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
<br />
Address:
<asp:TextBox ID="AddressTextBox" runat="server" Text='<%# Bind("Address") %>' />
<br />
Phone_Number:
<asp:TextBox ID="Phone_NumberTextBox" runat="server"
Text='<%# Bind("Phone_Number") %>' />
<br />
<asp:LinkButton ID="UpdateButton" runat="server" CausesValidation="True"
CommandName="Update" Text="Update" />
<asp:LinkButton ID="UpdateCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</EditItemTemplate>
<InsertItemTemplate>
Name:
<asp:TextBox ID="NameTextBox" runat="server" Text='<%# Bind("Name") %>' />
<br />
Address:
<asp:TextBox ID="AddressTextBox" runat="server" Text='<%# Bind("Address") %>' />
<br />
Phone_Number:
<asp:TextBox ID="Phone_NumberTextBox" runat="server"
Text='<%# Bind("Phone_Number") %>' />
<br />
<asp:LinkButton ID="InsertButton" runat="server" CausesValidation="True"
CommandName="Insert" Text="Insert" />
<asp:LinkButton ID="InsertCancelButton" runat="server"
CausesValidation="False" CommandName="Cancel" Text="Cancel" />
</InsertItemTemplate>
<ItemTemplate>
Name:
<asp:Label ID="NameLabel" runat="server" Text='<%# Bind("Name") %>' />
<br />
Address:
<asp:Label ID="AddressLabel" runat="server" Text='<%# Bind("Address") %>' />
<br />
Phone Number:
<asp:Label ID="Phone_NumberLabel" runat="server"
Text='<%# Bind("Phone_Number") %>' />
<br />
<asp:Button ID="Button3" runat="server" Text="Edit Details" CommandName="Edit" />
<br />
</ItemTemplate>
</asp:FormView>
<asp:SqlDataSource ID="SqlDataSource1" runat="server"
ConnectionString="<%$ ConnectionStrings:PetShopParadiseConnectionString %>"
SelectCommand="SELECT [Name], [Address], [Phone_Number] FROM [Vendors] WHERE ([VendorID] = #VendorID)">
<SelectParameters>
<asp:SessionParameter Name="VendorID" SessionField="ID" Type="Decimal" />
</SelectParameters>
</asp:SqlDataSource>
<br />
<asp:Table ID="Table1" runat="server" style="text-align:left;">
<asp:TableRow ID="TableRow4" runat="server">
<asp:TableCell ID="TableCell7" runat="server">Password</asp:TableCell><asp:TableCell ID="TableCell8" runat="server">
<asp:TextBox ID="PasswordBox" TextMode="Password" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator
id="RequiredFieldValidator5"
runat="server"
ControlToValidate="PasswordBox"
Display="None"
Forecolor="Red"
ErrorMessage="Please enter a password." />
</asp:TableCell></asp:TableRow><asp:TableRow ID="TableRow5" runat="server">
<asp:TableCell ID="TableCell9" runat="server">Re-Enter Password</asp:TableCell><asp:TableCell ID="TableCell10" runat="server">
<asp:TextBox ID="PasswordCheckBox" TextMode="Password" runat="server"></asp:TextBox>
<asp:RequiredFieldValidator
id="RequiredFieldValidator6"
runat="server"
ControlToValidate="PasswordCheckBox"
Display="None"
Forecolor="Red"
ErrorMessage="Please re-enter your password." />
</asp:TableCell></asp:TableRow></asp:Table><asp:Label
ID="PasswordLabel" runat="server" Text="Password" CssClass="style10"></asp:Label><br />
<asp:Button ID="PasswordButton"
runat="server" Text="Update Password" onclick="PasswordButton_Click" /><br />
<asp:SqlDataSource
ID="SqlDataSource2" runat="server"
ConnectionString="<%$ ConnectionStrings:PetShopParadiseConnectionString %>"
onselecting="SqlDataSource2_Selecting" SelectCommand="SELECT * FROM Vendors"
UpdateCommand="UPDATE [Vendors] SET [Password]=#passwordhash WHERE ([VendorID] = #VendorID)" OnUpdating="Parameters_Updating">
<UpdateParameters>
<asp:Parameter Name="Password" />
<asp:SessionParameter name="VendorID" sessionfield="ID" />
</UpdateParameters>
</asp:SqlDataSource>
<br /><asp:FileUpload ID="FileUpload1" runat="server" />
<asp:Button
ID="UploadButton" runat="server" onclick="UploadButton_Click" Text="Change Logo" /></div></asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="bannerContent" runat="server">
</asp:Content>
My guess is that it is causing other (possibly hidden) validation to run. Make sure to set CausesValidation to false.
quote :
*I just added the textbox methods *
I guess our trying to update a Password textBox which you can't.
only by :
PasswordLabel .Attributes["value"] = "aaa";

Resources