DropDownExtender In Ajax - c#

in my web page i want to place the ajax Dropdownexteder. but it is not working fine this is my code:
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:Label ID="lbldrp" runat ="Server" Text ="MyDropDown"></asp:Label>
<asp:Panel ID="Mypanel" runat ="Server" >
<asp:LinkButton ID ="linkmsn" runat ="Server" Text ="www.stackoverflow.com"></asp:LinkButton><br />
<asp:LinkButton ID ="linkgoogle" runat ="Server" Text ="www.google.com"></asp:LinkButton>
</asp:Panel>
<cc1:DropDownExtender ID="DropDownExtender1" TargetControlID ="lbldrp" DropDownControlID ="Mypanel" runat="server" >
</cc1:DropDownExtender>
<cc1:AnimationExtender ID="AnimationExtender1" TargetControlID ="Mypanel" runat="server">
<Animations>
<OnShow>
<HideAction Visible="true" />
</OnShow>
<OnHide>
<HideAction Visible="false" />
</OnHide>
</Animations>
</cc1:AnimationExtender>
</form>
it is giving some error like
"Animation on TargetControlID="Mypanel" uses property AjaxControlToolkit.AnimationExtender.OnShow that does not exist or cannot be set"
help me thank you.

Hai Sasidhar OnShow and Onhide are not valid properties of ajaxcontroltoolkit:animationExtender, instead u can use OnMouseOver for OnShow and OnMouseOut for OnHide
Look at this http://www.c-sharpcorner.com/UploadFile/raj1979/AnimationExtender01242008065540AM/AnimationExtender.aspx
or
http://www.asp.net/AJAX/AjaxControlToolkit/Samples/Animation/Animation.aspx and check its properties

Related

asp:button works locally but no on server

I have 4 asp:buttons on my web page. One of them works correctly the other three do not. The form on my web page is a simple encryption application. I am new to asp.net so any help would be greatly appreciated. The entire site works correctly locally of course but when uploaded on to the server 3 buttons don't work. I might be over looking something obvious but the sample code is below:
*Only the Encrypt button works.
Generic error code for other buttons:
ScriptResource.axd:5 Uncaught Sys.WebForms.PageRequestManagerServerErrorException: Sys.WebForms.PageRequestManagerServerErrorException: An unknown error occurred while processing the request on the server. The status code returned from the server was: 500
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
Enter Password: <asp:TextBox ID="TextBox1" MaxLength="15" CssClass="Password" runat="server"></asp:TextBox>
<asp:FileUpload ID="FileUpload1" CssClass="Button" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Upload File" CssClass="Button" CausesValidation="False" onclick="Button1_Click" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<br />
Enter Text:
<br />
<asp:TextBox ID="TextBox2" TextMode="MultiLine" CssClass="TestStyle" runat="server"></asp:TextBox>
<br />
<%--<asp:TextBox ID="TextBox2" TextMode="MultiLine" CssClass="TestStyle" runat="server"></asp:TextBox>
<br />--%>
<asp:Button ID="Encrypt" OnClick="EncryptBT_Click" runat="server" CssClass="Button" CausesValidation="False" Text="Encrypt"></asp:Button>
<asp:Button ID="Decrypt" OnClick="DecryptBT_Click" runat="server" CssClass="Button" CausesValidation="False" Text="Decrypt"></asp:Button>
<fieldset>
<legend>Save Encrypted Text File</legend>File name:
<asp:TextBox ID="textboxName" runat="server" Width="93px"></asp:TextBox>
<asp:Button ID="buttonSave" runat="server" Text="Save As" CssClass="Button" Width="66px" OnClick="Save_Click" /></fieldset>
</ContentTemplate>
</asp:UpdatePanel>
</form>
Check using developer Tools whether buttons are on the page or not.
Also, check whether their onClick method has been implemented or not in code -behind.

Conflicts Mootools Scriptmanager Ajax Asp.net?

I was trying differents ways to make this work but any success. I am trying to integrate mootools with an asp.net application. I just want to use it to add some effects to my site. I am also ussing update panels, scriptmanager because dont want full postbacks. On the console raise an error TypeError: clientID.startsWith is not a function and when make an update the brwoser reset....
This is the whole code. Hope help me and thanks agan!
<%# Master Language="C#" AutoEventWireup="true" CodeFile="Default.master.cs" Inherits="guiaEscoles" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title>Title go here</title>
<link href="~/css/main.css" rel="stylesheet" type="text/css" />
</head>
<body>
<form runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" LoadScriptsBeforeUI="true" EnablePartialRendering="true" >
<Scripts>
<asp:ScriptReference Path="~/scripts/mootools-core-1.4.5-full-compat-yc.js"></asp:ScriptReference>
<asp:ScriptReference Path="~/scripts/mootools-more-1.4.0.1-yc.js" ></asp:ScriptReference>
<asp:ScriptReference Path="~/scripts/jsecoles.js"></asp:ScriptReference>
</Scripts>
</asp:ScriptManager>
<asp:Panel runat="server" DefaultButton="" >
<asp:UpdatePanel runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:DropDownList runat="server" ID="DropDownListCountries" >
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</form>
</body>
</html>
<%# Page Title="" Language="C#" MasterPageFile="~/Default.master" AutoEventWireup="true" CodeFile="search.aspx.cs" Inherits="searchschool" %>
<%# MasterType VirtualPath="~/Default.master" %>
<asp:Content ID="ContentSearch" ContentPlaceHolderID="MainContent" runat="Server">
<div id="PlaceItem" runat="server">
<div id="ulLugar" class="">
<ul>
<li>
<asp:DropDownList runat="server" ID="DropDownListCountryBottom" AutoPostBack="true" OnSelectedIndexChanged="DropDownListCountryBottom_SelectedIndexChanged" EnableViewState="true">
</asp:DropDownList>
</li>
<li>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="DropDownListCountryBottom" EventName="SelectedIndexChanged" />
</Triggers>
<ContentTemplate>
<asp:DropDownList runat="server" ID="DropDownListCounty" OnDataBound="DropDownListCounty_DataBound" AutoPostBack="true" OnSelectedIndexChanged="DropDownListCounty_SelectedIndexChanged" EnableViewState="true">
</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</li>
<li>
<asp:DropDownList runat="server" ID="DropDownListDistrict" OnSelectedIndexChanged="DropDownListDistrict_SelectedIndexChanged" AutoPostBack="true" EnableViewState="true">
</asp:DropDownList>
</li>
</ul>
</div>
<div id="divStudies" >
<asp:CheckBox ID="CheckBoxStudies" runat="server" Text="<%$ Resources:Escoles, CheckBoxPQPILabel %>" OnCheckedChanged="CheckBoxStudies_CheckedChanged" AutoPostBack="true" />
</div>
<asp:Repeater ID="RepeaterThemes" runat="server" OnItemDataBound="RepeaterThemes_ItemDataBound">
<HeaderTemplate>
<ul>
</HeaderTemplate>
<FooterTemplate></ul></FooterTemplate>
<ItemTemplate>
<li class="liTema">
<asp:CheckBox ID="CheckBoxTheme" runat="server" OnCheckedChanged="CheckBoxTheme_CheckedChanged" AutoPostBack="true" EnableViewState="false" /></li>
</ItemTemplate>
</asp:Repeater>
<asp:UpdatePanel runat="server" UpdateMode="Always">
<ContentTemplate>
<asp:GridView runat="server" ID="GridViewEscoles" CellPadding="0" CellSpacing="0" BorderStyle="None">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label Text='<%# Eval("Field_1") %>' runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
here is the myjs file:
window.addEvent('domready', function () {
alert("Hello");
//var countTotal = $$('.liTema').length;
//alert(countTotal);
});
That is due to a conflict between mootools & Microsoft Ajax code, According to mootools they blamed the error on microsoft's code. I was looking for a solution but didn't find till now

Can't reference Image ID in C# Code. Why?

I would like to know, why I can't reference "asp:Image" (Image1) control in my code, but I can reference datalist control (DataList1) which contains asp:Image. Here is my code:
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div id="imageHolder">
<asp:DataList ID="DataList1" runat="server" RepeatColumns="4" Width="100%">
<ItemTemplate>
<asp:Image ID="Image1" OnDataBinding="DataList1_DataBinding" Width="80%" Height="100px"
CssClass="datalistImages" runat="server" ImageUrl='<%# "http://mywebsite.com/" + Eval("url") %>' />
</ItemTemplate>
</asp:DataList>
</asp:Content>
And I'm 100% sure I'm working in the correct class. Any suggestions?
Because it's in the item collection.
If you want to reach that image control at real time you have to use ItemCreated or ItemDataBound events.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datalist.items%28v=vs.110%29.aspx
Datalist events.
http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.datalist_events%28v=vs.110%29.aspx

fire a textbox's OnTextChanged while enabled=false

I have an ajax toolkit calendar extender attached to my textbox and i a trying to fire the OnTextChanged after the date was entered into the textbox.
The thing is i don't want the user to enter data manually so i disabled the textbox but the event won't fire for a disabled text box.
is there anyway around it? i thought about changing to a label but is doesn't have OnTextChanged event.
Thanks
<asp:TableCell CssClass="cssWidth" Width="150px">
<asp:CalendarExtender ID="CalendarExtender1" PopupButtonID="Image1" runat="server" TargetControlID="TextBoxAddDate" Format="dd/MM/yyyy"></asp:CalendarExtender>
<asp:TextBox ID="TextBoxAddDate" ReadOnly="true" CssClass="cssWidth" ToolTip="תאריך הוספה" runat="server" Style="font-size: large;background-color:aliceblue;" AutoPostBack="true" AutoCompleteType="Search" MaxLength="0" TextMode="SingleLine" OnTextChanged="txtSearch_TextChanged" ViewStateMode="Enabled" autocomplete="off" >
</asp:TextBox>&nbsp
<asp:ImageButton runat="Server" ID="Image1"
ImageUrl="~/Calendar_scheduleHS.png" AlternateText="Click to show calendar" /><br />
</asp:TableCell>
Can you use ReadOnly instead of Enabled = false?
UPDATE:
Ok, this is the complete solution that worked for me:
<%# Page Title="Home Page" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
CodeBehind="Default.aspx.cs" Inherits="WebApplication1._Default" %>
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
<script type="text/javascript">
function dateSelectionChanged(x) {
debugger;
javascript: __doPostBack('TextBoxAddDate', '')
}
</script>
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<h2>
Welcome to ASP.NET!
</h2>
<p>
To learn more about ASP.NET visit www.asp.net.
</p>
<p>
You can also find <a href="http://go.microsoft.com/fwlink/?LinkID=152368&clcid=0x409"
title="MSDN ASP.NET Docs">documentation on ASP.NET at MSDN</a>.
</p>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:CalendarExtender ID="CalendarExtender1" PopupButtonID="Image1" runat="server" TargetControlID="TextBoxAddDate" Format="dd/MM/yyyy" OnClientDateSelectionChanged="dateSelectionChanged" ></asp:CalendarExtender>
<asp:TextBox ID="TextBoxAddDate" CssClass="cssWidth" ToolTip="תאריך הוספה" runat="server" Style="font-size: large;background-color:aliceblue;" AutoCompleteType="Search" MaxLength="0" TextMode="SingleLine" OnTextChanged="txtSearch_TextChanged" ViewStateMode="Enabled">
</asp:TextBox>&nbsp
<asp:ImageButton runat="Server" ID="Image1"
ImageUrl="~/Calendar_scheduleHS.png" AlternateText="Click to show calendar" /><br />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
It seems that the CalendarExtender "steals" away the events from the texbox it uses.
Using this approach I managed to fire up the OnTextChanged event and the handler txtSearch_TextChanged gets executed.
Did you make the textbox ReadOnly?

Show a Loading Message using master pages while page loads data asp.net

I have spent hours Googling and searching past questions but have struggled to get anywhere with those answers (be it I can't get it into my solution correctly or it isn't suitable for me as they don't have master pages).
My question is, I have a couple of asp.net pages which can take a while to load (sometimes 5 seconds+) as there is a lot of data being requested from a database on the Page_Load method. To stop users from thinking that the page has crashed and either refreshing the page or doing something else, I want to put up a Loading message hiding everything else on the page (apart from the menu) while it loads.
I am using ASP.Net 4.0 with master pages and coding in C#.
The one where I get the most success is using the UpdatePanel on my master page where the content template covers the contentplaceholder, however I know this is not the best way to go about it and anyway it only shows up once, i.e. The user logs in, the loading message appears and once all the data has loaded on the home page (dashboard.aspx) the loading message disappears, which is kind of what I want. However if the user goes away from that page and then clicks home the loading message never appears again, just takes a while to load. It also never appears for any other page that takes a noticeable time to load.
Below is the body of the master.aspx
<body>
<form runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<div class="page">
<div class="header">
<div class="title">
<h1>
Header
</h1>
</div>
<div class="loginDisplay">
<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
<AnonymousTemplate>
[ Log In
]
</AnonymousTemplate>
<LoggedInTemplate>
Welcome <span class="bold">
<asp:LoginName ID="HeadLoginName" runat="server" />
</span>! [
<asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect" LogoutText="Log Out"
LogoutPageUrl="~/Default.aspx" />
]
</LoggedInTemplate>
</asp:LoginView>
</div>
<div class="clear hideSkiplink">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="false"
IncludeStyleBlock="false" Orientation="Horizontal" OnMenuItemClick="NavigationMenu_MenuItemClick">
<Items>
<asp:MenuItem Text="Home" />
<asp:MenuItem Text="About" />
</Items>
</asp:Menu>
</div>
</div>
<div class="main">
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
<asp:UpdateProgress ID="UpdateProgress1" runat="server">
<ProgressTemplate>
<asp:Panel ID="Panel1" runat="server" HorizontalAlign="Center">
<asp:Image ID="Image1" runat="server" ImageUrl="~/Images/loader.gif" />
</asp:Panel>
</ProgressTemplate>
</asp:UpdateProgress>
</ContentTemplate>
</asp:UpdatePanel>
<asp:UpdatePanelAnimationExtender ID="UpdatePanel1_UpdatePanelAnimationExtender"
runat="server" Enabled="True" TargetControlID="UpdatePanel1">
</asp:UpdatePanelAnimationExtender>
</div>
<div class="clear">
</div>
</div>
<div class="footer">
</div>
</form>
And below is the page for the dashboard.aspx (a page which has a long loading time)
<asp:Panel ID="PanelWelcome" runat="server">
<h1>
Welcome
<asp:Label ID="LabelUserName" runat="server" Text="[User Name]" /> to your
personal Dashboard.</h1>
<table width="100%" cellpadding="5px">
<tr>
<td style="width: 70%" valign="top">
<asp:Panel ID="Panel2" runat="server">
<p>
</p>
<h4>
Up and Coming </h4>
<br />
<asp:GridView ID="GridViewItin" runat="server" Width="100%" HorizontalAlign="Left"
OnRowDataBound="GridViewItin_RowDataBound">
</asp:GridView>
</asp:Panel>
</td>
<td style="width: 30%">
<asp:Panel ID="PanelProfile" runat="server">
<asp:ImageButton ID="ImageButtonProfile" runat="server" ImageUrl="~/Images/BlankProfile.jpg"
Width="150px" /><br />
<h4>
Name:</h4>
<asp:Label ID="LabelPARname" runat="server" Text="[Person Name]"></asp:Label>
<h4>
Company:</h4>
<asp:Label ID="LabelBARname" runat="server" Text="[Company Name]"></asp:Label>
<h4>
Date of Birth:</h4>
<asp:Label ID="LabelPARdob" runat="server" Text="[DOB]"></asp:Label><br />
<asp:LinkButton ID="LinkButtonProfilePage" runat="server" OnClick="LinkButtonProfilePage_Click">More details...</asp:LinkButton>
</asp:Panel>
</td>
</tr>
</table>
</asp:Panel>
Could you please show me the best way to go about it and where I am going wrong? Also how I can hide the ContentTemplate when the UpdateProgress template is showing that would be great?
Thanks.
Okay so I figured it out what I was doing wrong, I thought I would post what I did to hopefully help someone else who might end up with the same issues...
Basically I hadn't thought about it logically. There are controls outside the update panel such as a NavigationMenu which would never fire the update progress because they had nothing to do with the Panel! I had to add triggers to the update panel to deal with all the things that happen outside the panel.
So, in my master page I had the following code
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:ContentPlaceHolder ID="MainContent" runat="server" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="NavigationMenu" />
</Triggers>
</asp:UpdatePanel>
<asp:UpdateProgress ID="progress" runat="server" DynamicLayout="true" DisplayAfter="0">
<ProgressTemplate>
<div id="overlay">
<div id="modalprogress">
<div id="theprogress">
<asp:Image ID="loader" runat="server" ImageAlign="AbsMiddle" ImageUrl="~/images/loader.gif" />
Please wait...
</div>
</div>
</div>
</ProgressTemplate>
</asp:UpdateProgress>
<asp:UpdatePanelAnimationExtender ID="UpdatePanel1_UpdatePanelAnimationExtender"
runat="server" Enabled="True" TargetControlID="UpdatePanel1">
</asp:UpdatePanelAnimationExtender>
Hopefully that will help someone else!
You can use UpdateProgress control. You can get it From Toll box under Ajax Extensions Tab.
I am describing you a scenario:
Suppose I have One Upadate Panel name UpdatePnl1 , In that I have a Button Say GO.when we hit on go it should redirect to another page. before that it will promt you please wait.
Now my Code will be like that
<asp:UpdatePanel ID="UpdatePnl1" runat="server">
<ContentTemplate>
<asp:Button ID="BtnGO" runat="server" Text="GO" onclick="BtnGO_Click"/>
</ContentTemplate>
</asp:Updatepanel>
Button click code:
protected void BtnGO_Click(object sender, EventArgs e)
{
Response.Redirect("Example.aspx");
}
Now here is the code for UpdateProgress what you need to add
<asp:UpdateProgress ID="UpdateProgress1" runat="server" AssociatedUpdatePanelID="UpdatePnl1" >
<ProgressTemplate>
<asp:Label ID="LblWaitMsg" runat="server" Text="Processing Request, Please Wait..."></asp:Label>
</ProgressTemplate>
</asp:UpdateProgress>
Note: Your page Should contain ScriptManager.

Categories