Showing posts with label page. Show all posts
Showing posts with label page. Show all posts

Wednesday, March 28, 2012

AJAX Bug?

I have a page with an upper UpdatePanel that has 3 collapsible panel's and a lower UpdatePanel that has 2 gridviews in it. What happens is you select a list of employees and different training items in the upper UpdatePanel and a cross-tab grid is displayed in the lower UpdatePanel. Once the data is loaded into the cross-tab, it goes through every cell to update the text data to a graphical view of the data. So instead of 0 you would see a blank checkbox, and instead of 2 you would see a checked checkbox. The gridview columns are created dynamically based on what training selections were made. There can be as many as 400 training items at once and a couple hundred employees as well, so you can imagine how big the cross-tab grid can become if everything is selected. This page worked GREAT before I implemented ajax on it(I have my reasons), but now with AJAX in the page the cross-tab will only show if only a small number of employees or trainig items are selected. If you try to select every training item and every employee the whole program crashes in a very nasty way. Imagine losing the whole IE menu bars and start button, quickstart buttons, etc. The WHOLE screen becomes a jumbled mess. Any suggestions? Is this a bug or am I just trying to access too much data through AJAX?

JavaScript just flat out sucks with large amounts of data when looping.

You are probably causing JavaScript to have to loop through 1000's of form elements to figure out what is selected and build a string of that data to be posted. The freezing is the browser eating your CPU trying to crunch all of that data.

Eric


Thanks for the reply. I am starting to understand that this is the reason. Can you think of any workarounds? The only reason AJAX is being used on the page is to get the browser back button to work correctly so that the user can't click back and have someone's employee trained status revert to the previous state. Is there another way around this? Thanks.
hi.
i'm not sure if you're using updatepanels or are you wroking directly with javascript?
Here is a good post on JavaScript performance recommendations:http://blogs.msdn.com/ie/archive/2006/08/28/728654.aspx
Using Ajax
using Ajax.net with Update Panels.

AJAX breaks AdRotator control rendering

Hi,

Does anyone know how to resolve the issue I'm experiencing with AJAX breaking the AdRotator control?

My AdRotators reside in a master page and display fine until a AJAX UpdatePanel is introduced. Once an UpdatePanel is added the AdRotators start to render their HTML output at the very beginning of the page's HTML (before the

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
in my case).

Image without AJAX problem:http://x.yougodo.com/screenshot-good.jpg

Image with AJAX problem:http://x.yougodo.com/screenshot-bad.jpg

Any help would be greatly appreciated.

Cheers

I can't seem to find any other users with your issue. You may want to give this approach a try:http://www.seesharprun.net/2007/08/09/AnAdrotatorAlternative.aspx. Where is your AdRotator located on your MasterPage? I'm assuming you are adding your UpdatePanel inside the Master's ContentTemplate?

Perhaps you can post a small snippet of code that will replicate the issue?

-Damien


Hi Damien,

Thanks for your suggestion, much appreciated - I will take a look.

Was puzzled myself why no-one else seemed to have encountered the same problem?!?

The UpdatePanel is actually located in the *.aspx page rather than the *.master - I'll try and create a small example to re-create later as everything is too intertwined in my current project to post something useful.

P.S. The Google Ads in the screenshots are not in AdRotators, only the image ads you see.


How bizarre... I've not been able to recreate problem creating a simple AJAX / master page scenario?!?

Maybe it's down to some of my non-standard controls - all pages are inherited from my own Page class that adds a bunch of extra properties and methods useful for my project. The control triggering the AJAX callback is also my own roll-your-own page number selecting control.

Quite puzzled as both these own-code-rolled controls successfully use AJAX functionality on other pages. It's jut when the AdRotator is introduced that bizarre results occur. Quite puzzled!


That's interesting that you can't reproduce it. I think your assumption may be correct with your non-standard controls. Do you perhaps have an un-closed element or something? This could be causing some issues. You also may just want to make sure your AJAX environment is setup correctly, you can refer to these common problems/fixes:http://blogs.visoftinc.com/archive/2007/09/23/asp.net-ajax--updatepanel-not-working--common-problems.aspx.

Hope you find your problem!

-Damien


Hi Damien,

Cheers once again for your help - much appreciated. Doesn't seem to be any of the issues described in the link you gave though.

Very bizarre, the output would suggest that somehow the AdRotator is getting to render it's output before the *.master or *.aspx files do?!? No html at all is output to the locations where the AdRotator is placed, only at the top of the page before all other html. Very puzzling.

I've abandoned trying to find a solution for now, coding my own temporary random ad selector for now. The AdRotators were only ever going to be a temporary measure until a fully functioning ad management system is plugged in.

Gavin.

AJAX Beta 2 - Could not load type Microsoft.Web.UI.UpdateProgress from assembly Microsoft.

Hi...

I'm experiencing a problem with the new AJAX Beta 2. When I try and put the UpdateProgess on a simple page, I get the below

Could not load type 'Microsoft.Web.UI.UpdateProgress' from assembly 'Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.TypeLoadException: Could not load type 'Microsoft.Web.UI.UpdateProgress' from assembly 'Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Source Error:

Line 13: </head>
Line 14: <body>
Line 15: <form id="form1" runat="server">
Line 16: <div>
Line 17:


Source File:C:\Inetpub\wwwroot\Auction\TEST.aspx Line:15

Stack Trace:

[TypeLoadException: Could not load type 'Microsoft.Web.UI.UpdateProgress' from assembly 'Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.]
ASP.test_aspx.__BuildControlform1() in C:\Inetpub\wwwroot\Auction\TEST.aspx:15
ASP.test_aspx.__BuildControlTree(test_aspx __ctrl) in C:\Inetpub\wwwroot\Auction\TEST.aspx:1
ASP.test_aspx.FrameworkInitialize() in C:\Inetpub\wwwroot\Auction\TEST.aspx.vb:912307
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +40
System.Web.UI.Page.ProcessRequest() +86
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.test_aspx.ProcessRequest(HttpContext context) +29
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64

For the below code

<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %
<%@dotnet.itags.org. Register Assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
Namespace="Microsoft.Web.UI" TagPrefix="asp" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager id="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdateProgress id="UpdateProgress1" runat="server">
<progresstemplate>
<IMG src="Template/loading.gif" /> Working ... <asp:Image id="LoadingImage" runat="server" ImageUrl="Template/loading.gif"></asp:Image>
</progresstemplate>
</asp:UpdateProgress>
<asp:UpdatePanel id="UpdatePanel1" runat="server">
</asp:UpdatePanel>
</div
</form>
</body>
</html>
Please can you help, this is driving me nuts...Wink

Thanks,
Clint

Clint,

Did you try to add the assemby reference to the web.config file? You don't need to register it in the page, and you don't need it in the BIN folder.
Also, it seems that your copy of the assembly is still Beta 1, have you uninstalled Beta 1 and, then, reinstalled Beta 2? That will install the correct assembly in the GAC.

Cheers,

Juan


Hi Juan, thanks for your help.

I've uninstalled the Beta 2 and reinstalled a fresh copy from the internet, and I've also deleted the files in the BIN directory and the reference in the .aspx page.
In addition, I've replaced my web.config with the one that is created from a new web project including AJAX (I've included it below) But I am still getting this error.

Server Error in '/Auction' Application.

Could not load type 'Microsoft.Web.UI.UpdateProgress' from assembly 'Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Description:An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details:System.TypeLoadException: Could not load type 'Microsoft.Web.UI.UpdateProgress' from assembly 'Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

Source Error:

Line 8: </head>
Line 9: <body>
Line 10: <form id="form1" runat="server">
Line 11: <div>
Line 12: <asp:ScriptManager id="ScriptManager1" runat="server">


Source File:C:\Inetpub\wwwroot\Auction\Default2.aspx Line:10

Stack Trace:

[TypeLoadException: Could not load type 'Microsoft.Web.UI.UpdateProgress' from assembly 'Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.]
ASP.default2_aspx.__BuildControlform1() in C:\Inetpub\wwwroot\Auction\Default2.aspx:10
ASP.default2_aspx.__BuildControlTree(default2_aspx __ctrl) in C:\Inetpub\wwwroot\Auction\Default2.aspx:1
ASP.default2_aspx.FrameworkInitialize() in C:\Inetpub\wwwroot\Auction\Default2.aspx.vb:912307
System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +40
System.Web.UI.Page.ProcessRequest() +86
System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18
System.Web.UI.Page.ProcessRequest(HttpContext context) +49
ASP.default2_aspx.ProcessRequest(HttpContext context) +29
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64


Here is my code...

<%@. Page Language="VB" AutoEventWireup="false" CodeFile="Default2.aspx.vb" Inherits="Default2" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager id="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdateProgress id="UpdateProgress1" runat="server">
<progresstemplate>
<IMG src="Template/loading.gif" /> Working ... <asp:Image id="LoadingImage" runat="server" ImageUrl="Template/loading.gif"></asp:Image>
</progresstemplate>
</asp:UpdateProgress>
<asp:UpdatePanel id="UpdatePanel1" runat="server">
</asp:UpdatePanel>
</div
</form>
</body>
</html>

And here is my new web.config

<configuration>
<configSections>
<sectionGroup name="microsoft.web" type="Microsoft.Web.Configuration.MicrosoftWebSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="Microsoft.Web.Configuration.ScriptingSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="webServices" type="Microsoft.Web.Configuration.ScriptingWebServicesSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="Microsoft.Web.Configuration.ScriptingJsonSerializationSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
<section name="profileService" type="Microsoft.Web.Configuration.ScriptingProfileServiceSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
<section name="authenticationService" type="Microsoft.Web.Configuration.ScriptingAuthenticationServiceSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<connectionStrings>
<remove name="AuctionConnectionString"/>
<add name="AuctionConnectionString" connectionString="Data Source=ALEPPO;Initial Catalog=Auction;Persist Security Info=True;User ID=sa;Password=" providerName="System.Data.SqlClient"/>
<add name="SMSINTv2ConnectionString" connectionString="Data Source=ALEPPO;Initial Catalog=SMSINTv2;Persist Security Info=True;User ID=sa;Password=" providerName="System.Data.SqlClient"/>
</connectionStrings>
<system.web>
<pages>
<controls>
<add tagPrefix="asp" namespace="Microsoft.Web.UI" assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagPrefix="asp" namespace="Microsoft.Web.UI.Controls" assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
<tagMapping>
<add tagType="System.Web.UI.WebControls.CompareValidator" mappedTagType="Microsoft.Web.UI.Compatibility.CompareValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.CustomValidator" mappedTagType="Microsoft.Web.UI.Compatibility.CustomValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RangeValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RangeValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RegularExpressionValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RegularExpressionValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RequiredFieldValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RequiredFieldValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.ValidationSummary" mappedTagType="Microsoft.Web.UI.Compatibility.ValidationSummary, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</tagMapping>
</pages>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
--><compilation debug="true">
<assemblies>
<add assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</assemblies>
</compilation>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET" path="ScriptResource.axd" type="Microsoft.Web.Handlers.ScriptResourceHandler" validate="false"/>
</httpHandlers>
<httpModules>
<add name="WebResourceCompression" type="Microsoft.Web.Handlers.WebResourceCompressionModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptModule" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</system.web>
<microsoft.web>
<scripting>
<webServices>
<!-- Uncomment this line to customize maxJsonLength and add a custom converter -->
<!--
<jsonSerialization maxJsonLength="500">
<converters>
<add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>
</converters>
</jsonSerialization>
-->
<!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate. -->
<!--
<authenticationService enabled="true" requireSSL = "true|false"/>
-->
<!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved
and modified in Atlas applications, you need to add each property name to the setProperties and
getProperties attributes. -->
<!--
<profileService enabled="true"
readAccessProperties="propertyname1,propertyname2"
writeAccessProperties="propertyname1,propertyname2" />
--></webServices>
</scripting>
</microsoft.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-ISAPI-2.0"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptResource" verb="GET" path="ScriptResource.axd" type="Microsoft.Web.Handlers.ScriptResourceHandler"/>
</handlers>
</system.webServer>
</configuration>

Hi...

I've managed to fix it thanks ...

I tried creating a new project and copying the files across to it, and it worked!? Very Strange!?

Any Idea why this would be, even after I copied the entire now working project files back to the original folder that wasn't working, it still did not work??

Thanks for your help,
Clint


I don't know if this helps any or not, but I was originally getting the same error and this is how i resolved it:

*I should first mention I had Beta1 and the ValueAdd CTP implemented prior to Beta2. (I had implemented them simply by copying the Microsoft.Web.Extensions.dll and Microsoft.Web.Preview.dll to the app's Bin folder):

To implement Beta2 I followed the doc instructions (web.config modification), and deleted the 2 dll's from the Bin folder (and removed the web.config references to the ValueAdd piece).

That's when I started getting the same error you were.

UNTIL I restarted IIS. I'm guessing it (or ASP.NET) had the old dll's cached somewhere since I originally had them in the bin folder??

Hope it helps-

Kenneth


The assemblies are in the GAC, cached, etc. Restarting IIS as suggested below worked for me too.

AJAX Beta 1 and PageMethods Error

Hello,
I'm using the PageMethods to call page methods. All works with the ATLAS CTP.
With the new AJAX Beta 1 I have an error: PageMethods is undefined. I don't think it's a problem of my web.config. If i create a new ASP.NET AJAX Enabled Web Site I have the same error.

Someone have the same error? Is it a bug? Is it a beta 1 change?

Thanks,
Alessadro

hello.

make sure that your page method is public and STATIC (this is a change from the previous ctp version). btw, make sure that the method receives all the values that it needs to perform its calculations since now you don't get access to the controls maintained on the page.


I have checked all this things before posting.
My methods are public and static and have the attributes Microsoft.Web.Script.Services.ScriptMethod and WebMethod.
They use only local variables and don't access any page controls.

I think that the error is different: PageMethods is undefined. I have this javascript error, so I don't think it's a problem with my methods. It's the PageMethods that is not defined.
If i define a simple method that return an integer, I have the same error. And I have the same error if i create a new ASP.NET AJAX Enabled web site project too.


hello again.

if i recall correctly, you just need to use the webmethod. here's a quick example i have here:

<%@. Page Language="C#" %>
<%@. Import namespace="LivroAtlas"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
[System.Web.Services.WebMethod]
public static Aluno[] ObtemAlunos()
{
Aluno[] alunos = new Aluno[]{
new Aluno( "João", 15 ),
new Aluno( "Rita", 16 ),
};

return alunos;
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager runat="server" ID="manager" />
<input type="button" value="invocar método da página" onclick="handle()" />
</form>
<script type="text/javascript">
function handle()
{
PageMethods.ObtemAlunos( handleCallback);
}
function handleCallback( res )
{
for( var i = 0; i < res.length; i++ )
{
alert( res[i].Nome + "-" + res[i].Idade );
}
}
</script>
</body>
</html>

btw, if you check the source of your page and don't see the global variable PageMethods, then that means that the ScriptManager is not injecting the proxy for the methods on the client side...


Finally I resolved the problem.
The solution is describe in this post from Shawn Burke's Blog. Due to a bug in this release of AJAX the page method must be in the same ASPX Page and not in codebehind.


Did you do anything to get the PageMethods object to appear on your page?

I've got public static void, I've got WebMethod and ScriptMethod, and I've got the function in the page rather than the code-behind... still nothing.


what the.......

okay... apparently closing the project, leaving it overnight, and changing absolutely nothing... fixed it... what do ya know. :p


This will break too much of my code...I think I will revert back to ATLAS until this is resolved/changed.

AJAX best-practice page design

This may seem like a trivial question, but I have been away from web-based programming for some time and am not sure what the current best-practice is for page layout. Over the years there have been many approaches to web page design: frames, tables, masterpages, etc...

I'm asking because i'm trying to make an AJAX web-app with toolbars above and to the side of the content. Take a look at the current pages atwww.stairmand.com. There isn't any real content linked to the menus, but its enough to demonstrate my question. I managed to place the content in the correct position using an iframe (which i don't like), but i'd like to acheive an AJAX style content area... with "loading"images, etc. The problem is that the content is all dynamically generated in asp.net too, and I haven't worked out a way to place this in a div dynamically.

I'm sure there must be a really simple way to do this, either directly using javascript or one of the Ajax Toolkit components, but i'm stuck! I manage to put a static html string into a div with no problem, but how do i do this with dynamic pages - for example to return a datagrid. Help!!!!

if you want a page that is changed depending on selections made above and to the side menus of the page i would use a masterpage with a iframe. The master page can then use its menu options to tell the iframe where to go while keeping the menus in their current state


Ok.. in that case it seems like i'm doing the right thing. Is it possible to show an "updating" image while the i frame is loading?


yes, using ajax you can place this item called the "UpdateProgress" on a page. Basically you tie this to an update panel and set a time in milliseconds. This time determins after how long of the update panels loading time should the contents of the updateprogress should be shown. So if updateProgress contaings the word loading and a .gif pic that spins around, as soon as the update panel has spent more then the entered amount of time loading, the text and image will be shown to the user and take away when the panel is loaded

better yet just watch this, it will show you everything

http://www.asp.net/learn/videos/view.aspx?tabid=63&id=123


Excellent.

Thanks very much for your help!


no problem. if this info helped please mark as an answer, it gimes me points, which boost my confidence in all aspects of my lifeHmm


You can use UpdateProgress Control for it..

Here you will get details..

http://ajax.asp.net/docs/overview/UpdateProgressOverview.aspx

AJAX becomes full postback in IIS

I made a simple AJAX page in Visual Studio 2005, which has a button click to get server's system time. It works fine inside the VS2005. But when I put it on IIS in Windows Server 2003, the button click becomes a full postback. Do I miss something? Does anyone have any idea?I wrote a testing Ajax website to get server time in a asp:UpdatePanel and deplyed it to Windows Server 2003 IIS.It worked fine and didn't?happen?to full postback.Here are my sample codes for your reference.Wish this can give you some helps.
<div>
<asp:UpdatePanel ID="upnlServerTime" runat="server">
<ContentTemplate>
<asp:Label ID="lblServerTime" runat="server" Text="Server Time"></asp:Label>
<asp:Button ID="btnServerTime" runat="server" Text="Get Server Time" OnClick="btnServerTime_Click" />
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnServerTime" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
Behind Code:
protected void btnServerTime_Click(object sender, EventArgs e)
{
Label lblServerTime = upnlServerTime.FindControl("lblServerTime") as Label;
lblServerTime.Text = DateTime.Now.ToLongTimeString();
}


I doubt you don't create web application when you create a virtual directory in IIS.Right mouse click virtual directory in IIS and select Properties,Click "Create" button to create application name and Choose Execute Permission for "Scripts only" or "Scripts Executable" from permission DropDownList.Try to addNetwork Service to virtual directory?when?deploying?Ajax?
website.
Wish this can give you some ideas.

Ajax based Tab control.

Hi all,

I need a Menu control horizontally laid out at the top the screen on a master page as shown below.

Tab1 Tab2 Tab3 Tab4 Tab5

Each tab would navigate to a different page, Tab1 to Page1.aspx, Tab2 to Page2.aspx, ...Tabi to Pagei.aspx etc.

Is it possible to change between different tabs(pages) in a Ajaxy way(so that the user doesnt see the flicker or the progress bar at the bottom of browser on the task bar),

I see that UpdatePanel does not integrate well with asp:menu, and a I saw a couple of posts where people have used the CallBack feature of asp.net 2.0 to attain the effect. Is this the only solution?


Thanks for your time

try it.....

Master.aspx File

<%@. Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<link href="http://links.10026.com/?link=StyleSheet.css" rel="stylesheet" type="text/css" />
<title>Master Page ::</title>
</head>
<body>
<form id="form1" runat="server">
<table cellpadding="0" cellspacing="0" id="MasterContainer" width="100%">
<tr>
<td id="BannerContainer" align="left" colspan="2">
Tab Demo Site
</td>
</tr>
<tr>
<td id="ContentContainer" valign="top" style="height: 19px">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td colspan="2">
<table cellpadding="0" cellspacing="0" border="0" width="100%" class="TabMenuContainer">
<tr>
<td>
<asp:Menu CssClass="TabMenu" DataSourceID="TabMenuSitemap" HideSelectElements= "True" ID="Menu2" Orientation="Horizontal" runat="server">
<StaticSelectedStyle CssClass="TabMenuItemSelected" />
<StaticMenuItemStyle CssClass="TabMenuItem" />
<StaticMenuStyle CssClass="SiteStaticMenu" />
<StaticHoverStyle CssClass="TabMenuItemHover" />
<DataBindings>
<asp:MenuItemBinding DataMember="SiteMapNode" Depth="0"
NavigateUrlField="Url" TextField="Title" ToolTipField="Description" />
</DataBindings>
</asp:Menu>
</td>
<td class="TabMenuSpacer" width="100%"></td>
</tr>
</table>
</td>
</tr>
<tr>
<td width="100%" valign="top">
<div id="SiteContent">
<asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
</asp:ContentPlaceHolder>
</div>
</td>
<td>
<div class="SiteContentSpacer"></div>
</td>
</tr>
</table>
</tr>
</table>
<asp:SiteMapDataSource ID="TabMenuSitemap" runat="server" ShowStartingNode="false" />
</form>
</body>
</html>

WEb.sitemap File

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/ AspNet/SiteMap-File-1.0" >
<siteMapNode url="" title="" description="" roles="*">
<siteMapNode url="~/default.aspx" title="My WebPage" description="The Home Page" roles="*" />
<siteMapNode url="~/default2.aspx" title="My WebPage 1" description="The First Tab" roles="*" />
<siteMapNode url="~/default3.aspx" title="My WebPage 2" description="The Second Tab" roles="*" />
</siteMapNode>
</siteMap>

Smile

ajax based page need to go to the top of the page....

Hi everyone ,,,

i have a page that contain update panel , that uses partial rendering ..

i need to go to the top of the page after postBack ... how do i do this ?

thnx ..


Why would you want a postback if you are using Update PanelSmile

The Update Panel and other partial rendering sections are solely meant for avoiding the page from going to the top for each and every action and retainng the scroll position.

Is there a specific reason you want the page to scroll up?


i need it because i have a gridview at the bottom of the page that i select a row from it ,

and i get an information about the row at the top of the page , if i have a lot of rows when i select a row i stay on the position of the row and the info is not display for

the user, the user need to scroll to the top of the page ..



Use this Peace of Code:
-------------------------------
<!--Add the following after the scriptmanager on your page:-->

 <script type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(EndRequestHandler);
function EndRequestHandler(sender, args) {
window.scrollTo(0,0);
}
</script>

--------------------------------

If that doesnt work for some reason, try this

Use HTML Bookmarks to achieve this without a Postback

1) Place HTML Bookmark <a name="top" >TOP</a> on Top of the Page

2) Use Response.Redirect("PageURL#top) to go to the top of the page

Read more about Bookmark on this:
http://www.freewebmasterhelp.com/tutorials/html-basics/4

Shrinand Vyas

ajax based masterpage

can any1 tell:

ajax based masterpage template i found in vs 2k8 but didn't get its purpose

i redirect from 1 page to another page of my site but don't wanna rerender/refresh contents of master page. i think this thing can do this but how not sure as i tried but it postback :) may b m wrong or doing wrong

Any time you go to a new page, even a page that has the same master as the current page you're on, you are going to have a full page refresh. Only partial page updates on the same page can be "hidden".

Ajax Based Login Control

How can I have ajax based login on my website home page ? How can I use built in login control in asp.net 2.0 to implement ajax ..

I want a login functionality as we use in gmail kindly guide me please

This really depends on how you do your login page. If you're login page is a seperate page (than the rest of your app), AJAX will only help you in that it will not "flick" when someone enter's wrong credentials.

However, if you have a "login" control that is added to a page if they're not logged in, you can use an AJAX callback to add that control do the page. You can use UpdatePanels if you need.


I have my login Control with in the page but i want to sent only that login form to server and remain rest page as it is ...how to do this pls guide


hello.
well, you do have some options here. for instance, you can use the client side validation services and build a simple form that will do just that.
http://www.asp.net/ajax/documentation/live/tutorials/UsingFormsAuthenticationTutorial.aspx

AJAX Baby Steps - removing an item

i am working on my first little ajax project.

Basically i have no idea how to start. I created a AJAX enabled website and i have a simple page on there that basically has a list of items taken from a Class thats stored in the session.

So I have

1 Gridview that bases its DataSource to a Dataset i create from a object (just a class that contains an array list)

2. I have methods in place to loop through the array list, create a datatable and bind it to the gridview

3. I have a method that also removes a selected item from a dataset and refreshes the gridview its a "remove" button.

I would like to have AJAX handle the removal of items (for now, eventually i want the whole thing ajax enabled) but just to start i want to just activate my Remove method from ajax.

But i dont know where to go from here.

So what do i have to do to call my method via AJAX ?

Any advice or help appreciated!

thanks

mcm

well i seem to have figured it out although i dont know what i did or how it works!

I added the ScriptManager tag to the page.

I added an UpdatePanel surrounding my Gridview,

and now my REMOVE buttons work without postbacks!

Holy Momma! How did it do it?!? I thought i'd have to be writing javascript and hooking into new events , etc.

is it REALLY all this easy?

mcm


Yep, it can really be that easy. caveat, though; the UpdatePanels can get pretty heavy in terms of resource requirements if you use them extensively, and there are also issues with certain combinations of controls (witness the volume on the forum of "Update panel and my..." posts. For simple things like you're describing, they work very well, though.

great! So now that i have seen how easy it "can be". I do have a couple more questions.

I created a sample AJAX enabled site to test this bin and it works GREAT im so impressed with myself.

But how complicated is it going to be to make this a component. My idea for the site is to use Master Pages (another first for me)

and down the left side this "component" will sit. I still dont know wether to make it a component or just a content page.

There will be a repeater or a formView on the right with products to add to the bin. I want those to be ajax enabled too. Is it hard to make different elements in different content pages "speak" to each other? Really all im doing (as stated in the first post) is adding items to a Collection stored in a Session Variable (using a facade pattern with a SessionManager class)

Also. I am using the new Web Application templates to build my stuff (from ScottGu's blogs) Can i switch this AJAX enabled site to be a WEb Application and keep the functionality?

thanks,

mcm

Monday, March 26, 2012

AJAX Auto Complete with sql look-up

Ok he's the thing,

I have the following auto complete on a aspx page for a seach function, im wanting it to look-up the names using the sql on line 20

1<ajaxToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server">2 <Services>3 <asp:ServiceReference Path="AutoComplete.asmx" />4 </Services>5 </ajaxToolkit:ToolkitScriptManager>6 <h1>7 Search Page</h1>8 <table>9 <tr>10 <td>11 <asp:TextBox ID="searchTextBox" runat="server"></asp:TextBox></td>12 <td style="width: 100px">13 <asp:Button ID="searchButton" runat="server" Text="Search" /></td>14 </tr>15 </table>16 <ajaxToolkit:AutoCompleteExtender runat="server" ID="autoComplete1" TargetControlID="searchTextBox"17 ServicePath="AutoComplete.asmx" ServiceMethod="GetCompletionList" MinimumPrefixLength="2"18 CompletionInterval="1000" EnableCaching="true" CompletionSetCount="12">19 </ajaxToolkit:AutoCompleteExtender>20 <asp:SqlDataSource ID="autoCompleteSqlDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:autoCompleteConnectionString%>" SelectCommand="SELECT [fishName] FROM [tblFishTypes]"></asp:SqlDataSource>

Then i've the following code in the asmx file...

1Imports System.Web2Imports System.Web.Services3Imports System.Web.Services.Protocols4Imports System.Collections.Generic56<WebService(Namespace:="http://tempuri.org/")> _7<WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _8<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _9<System.Web.Script.Services.ScriptService()> _10Public Class AutoComplete11 Inherits System.Web.Services.WebService1213 <WebMethod()> _14 Public Function GetCompletionList(ByVal prefixText As String, ByVal count As Integer) As String()15 Dim c1 As Char16 Dim c2 As Char17 Dim c3 As Char1819 If (count = 0) Then20 count = 1021 End If2223 Dim rnd As New Random()2425 Dim items As New List(Of String)2627 For i As Integer = 1 To count2829 c1 = CStr(rnd.Next(65, 90))30 c2 = CStr(rnd.Next(97, 122))31 c3 = CStr(rnd.Next(97, 122))3233 items.Add(prefixText + c1 + c2 + c3)34 Next i3536 Return items.ToArray()37 End Function3839End Class

Now i know i need to swap out the lines 23-33 and point instead to my sql connection string... right? but how? The random chaaters work but i want to limit the autocomplete to my database
Thanks Dooie

The data source declared on the ASPX page is out of the scope on the web service. Create a SQL Data Reader and create an array of fish names from within the method.


Nope sorry, im still lost, could explain a little further?


Hi,

You can replace them by creating a SqlDataAdapter to fetch data from database.

Hereis an example of using SqlDataAdapter.

Ajax auto complete extender

I am using ajax autocompleteextender. I have declared the service method in the user control itself instead of declaring it in aspx page. But the extender does not work .How can i do it? I want to declare it in ascx page,as i will be reusing the component.

my master page script
=====================
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true" EnablePartialRendering="true"/asp:ScriptManager
my aspx page where i am inheriting masterpage
==============================================

<%@. Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="frmTestAuto.aspx.cs" Inherits="frmTestAuto" Title="Untitled Page" %>
<%@. Register src="http://pics.10026.com/?src=ctlAutoExtender.ascx" TagName="ctlAutoExtender" TagPrefix="uc1" %>
<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server" /asp:ScriptManagerProxy>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>TEST AUTO PAGE</td>
</tr>
<tr>
<td>uc1:ctlAutoExtender ID="CtlAutoExtender1" runat="server" /</td>
</tr>
<tr>
<td>Footer</td>
</tr>
</table>
</asp:Content
my ascx page
=============
<%@. Control Language="C#" AutoEventWireup="true" CodeFile="ctlAutoExtender.ascx.cs" Inherits="ctlAutoExtender" %>
<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>
<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server"></asp:ScriptManagerProxy>
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td>
<asp:TextBox runat="server" ID="myTextBox" Width="300" />

<ajaxToolkit:AutoCompleteExtender runat="server" ID="autoComplete1" TargetControlID="myTextBox" Enabled="true"
ServiceMethod="GetCompletionList" ServicePath="ctlAutoExtender.ascx.cs" MinimumPrefixLength="3"
CompletionInterval="1000" EnableCaching="true"
CompletionSetCount="12"/>
</td>
</tr>
</table
my ascx.cs page
===============

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Web.Services;
using System.Web.Script.Services;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]

public partial class ctlAutoExtender : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{

}

[WebMethod]
[ScriptMethod]
public static string[] GetCompletionList(string prefixText, int count)
{
string sql = String.Format("select clt_tVLongNm from mclient where clt_tVLongNm like @.companyname + '%'");

List<string> companyList = new List<string>();

using (SqlConnection connection = new SqlConnection("server=192.168.2.57;uid=sa;pwd=d28rg6yp;database=fnocash_report"))

using (SqlCommand command = new SqlCommand(sql, connection))
{
connection.Open();
command.Parameters.AddWithValue("@.companyname", prefixText);
using (SqlDataReader reader = command.ExecuteReader())
{
while (reader.Read())
{
companyList.Add(reader.GetString(0));
}
}
}
return companyList.ToArray();
}
}

please help me out asap


Hi,

In ASP.NET, a request for a .ascx file will be?handled?by?System.Web.HttpForbiddenHandler?HttpHandler,?that's?to?say,?it's?refused.
So you can't use a method in the UserControl, I suggest trying to use a web service(.asmx) to achieve this.
Hope this helps.

Hi,

I am declaring the autocompleteextender in the user control. So, should I give service path for the extender as .asmx file in the extender?

eg:

My ascx page:

<%

@.ControlLanguage="C#"AutoEventWireup="true"CodeFile="ctlAutoExtender.ascx.cs"Inherits="ctlAutoExtender" %>

<%

@.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="ajaxToolkit" %>

<

tablecellpadding="0"cellspacing="0"border="0"width="100%"><tr><td><asp:TextBoxrunat="server"ID="myTextBox"Width="300"/>

<ajaxToolkit:AutoCompleteExtenderrunat="server"ID="autoComplete1"TargetControlID="myTextBox"Enabled="true"ServiceMethod="GetCompletionList"ServicePath="App_Code/WebService.cs"MinimumPrefixLength="3"CompletionInterval="1000"EnableCaching="true"CompletionSetCount="12"/></td></tr>

</

table>


Yes,?like?this:??ServicePath="the relative path of the .asmx file"
Thanks, that solved my problem.

Ajax Asynchronous, is it possible ?

Hi,

Say i have a server process which listens for some changes in database.
When a change occurs i want to refresh my page in browser by notyfinig it.

I do not want to refresh my page i.e. every 5 seconds, i just want to refresh it ONLY on server change just like desktop applications do.

The problem is that refreshing evry n seconds has to much impact on my web server. The refresh action should be taken only when something really happens that makes sense

Is it possible ?

greets, peter

Take a look at this, I think it's exactly what you need:http://encosia.com/index.php/2007/07/25/display-data-updates-in-real-time-with-ajax/

It does poll the server, but allows you to use a very light weight polling call and only trigger a partial postback if it's needed.


I had to do this in an application I wrote recently. What I did was basically the same method as above, but I used web services instead of doing a full postback.It seemed to work quickly enough to manage, and kept all the code nice and separated. You just call the webservice and have it check the database for new data, and update accordingly.

Ajax asynchronous postback

Hi all,

I have created a web page with ajax support. In that i have two buttons and three textbox.

All the three textboxes having required field validator attached to them. Now while i am trying to do asynchronous postback it is not possible for me because the required field validator prompts me to enter values. Is there any way to get rid of this...

I would like to do asynchronous postback even though ther are validators on the page

Do u set the same value to propertie ValidationGroup for validators and the button that cause the validation?


 This will not cause validation :
 <asp:button ID="someButton"CausesValidation="false" runat="server" />

Hi SathishRaja,

My understanding of your issue is that you want to get rid of the validation when click the button which will normally fire the validators. If I have misunderstood, please feel free to let me know.

As far as I know, there are three methods to achieve this list below:

Solution 1


Thanks Solution 2 is Working fine for me.

AJAX animation panel

Hello forum! I have an aspx page with a panel, 1 button and 2 animation extender. The button is associated to one of the animation extender and it has in the property "OnClientClick"=return false;

This is all working well.

In the panel I have 1 label that I want is values to change always I click in the button. But, because of the property "OnClientClick"=return false; all the code that I have in the OnClick of the Button doesn't work! If I took of the property, the animation panel don't show...

Here is the code I have in my button:

Protected Sub btnInfo_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnInfo.Click

lbl_name.Text = "Liliana"

End Sub

Please help me!!

Thanks

????????????????

Liliana

Portugal

Hi Liliana

As far as i know, there is no way to do waht you want to do in that method. The button either works on the client OR the server not both

However, you could add a page method to populate the button's click event like this

<asp:button id="btnLilianaButton" runat="server" Text="Click Me" OnClientClick='<%# LilianaPageMethod()%>' />

and on the Page code-behind have a method like this

public string LilianaPageMethod(){return"javascript:$get('" + lbl_name.ClientID +"').innerText = 'Liliana';return false;";}

This statement is evaluated when the page is rendered only so is pretty static. You could also use a WebMethod via javascript if you so wished and this could interact fully with the server

Hope this helps


Tim


Hello Tim! Thanks for your help but I solve the problem by other way.

I put the panel inside an AJAX Update Panel and the code inside the Load Event of the Update Panel. And it works fine!

Thanks,

Liliana

ajax animation extender pls help

Hello all I had designed my website with help of ajax extensions in that project i had designed master page and this page inherits some another pages but whenever user goes inside the link i want to disable some of the links which presents on the master page .

i am using animation extender ,when animation flyout on button clik then i want only animated div tag and disable all background page.

I want to use same functionality as asp.net forum uses when user click's on select tags button .

whenever uses select that topic only animation is enabled on the page and background is disable

you can see this functionality by posting a query on asp.net fourm

thank you

ravi amber

Hi Ravi amber,

I'm failed to get clear enough with your question. So would you please explain what you want more clearly? Thanks.

ravi.ambar:

but whenever user goes inside the link i want to disable some of the links which presents on the master page .

i am using animation extender ,when animation flyout on button clik then i want only animated div tag and disable all background page.

I want to use same functionality as asp.net forum uses when user click's on select tags button .

What are these really mean??

Best regards,

Jonathan

AJAX and window.open dos not work

Hi,

I Have Page that uses AJAX Update panel and with in the panel i have button that contans the following

Response.Write("<script>window.open('default2.aspx',target='new');</script>")

when i click the button exception will happen saying that can not parse from the server.

any one out there that can help me solve this problem..

Thanks

If AJAX is used in your webpage, that script doesn't work anymore.

I guess you could do like below:

<asp:Button ID="btn1" runat="server" Text="OpenNew" OnClientClick="OpenNew();"></asp:Button><input type="hidden" id="hidFlag" runat="server" value="False"/><script type="text/javascript">function OpenNew(){ setInterval('Open()', 100);}function Open(){ flag = document.getElementById('hidFlag'); if (flag) { if (flag.value !='False') { window.open('default2.aspx', target='new'); flag.value ='False'; } }}</script>Code Behind:Protected Sub btn1_Click(byval sender asObject, byval e as EventArgs)Handles btn1.Click hidFlag.value ="True"End Sub

JasonMDLi:

If AJAX is used in your webpage, that script doesn't work anymore.

I guess you could do like below:

<asp:Button ID="btn1" runat="server" Text="OpenNew" OnClientClick="OpenNew();"></asp:Button><input type="hidden" id="hidFlag" runat="server" value="False"/><script type="text/javascript">function OpenNew(){ setInterval('Open()', 100);}function Open(){ flag = document.getElementById('hidFlag'); if (flag) { if (flag.value !='False') { window.open('default2.aspx', target='new'); flag.value ='False'; } }}</script>Code Behind:Protected Sub btn1_Click(byval sender asObject, byval e as EventArgs)Handles btn1.Click hidFlag.value ="True"End Sub

I've got the same issue asazuomar. What if the url for the new window is not fixed but has parameters, let's say, window.open('default2.aspx?query=4323',target='new'), and the "query" parameter has the value from some calculation that occurs inside the event btn1_Click (in your sample). What then?


nistam:

I've got the same issue asazuomar. What if the url for the new window is not fixed but has parameters, let's say, window.open('default2.aspx?query=4323',target='new'), and the "query" parameter has the value from some calculation that occurs inside the event btn1_Click (in your sample). What then?

You can pass the value to the hidden control "hidFlag" or to another hidden control.

<asp:Button ID="btn1" runat="server" Text="OpenNew" OnClientClick="OpenNew();"></asp:Button><input type="hidden" id="hidFlag" runat="server" value="False"/><input type="hidden" id="hidFlagValue" runat="server" value=""/><script type="text/javascript">function OpenNew(){ setInterval('Open()', 100);}function Open(){ flag = document.getElementById('hidFlag'); flagvalue = document.getElementById('hidFlagValue'); if (flag && flagvalue) { if (flag.value != 'False') { window.open('default2.aspx?query='+flagvalue.value, target='new'); flag.value = 'False'; } }}</script>

Code Behind:
Protected Sub btn1_Click(byval sender asObject, byval e as EventArgs)
Handles btn1.Click
hidFlagValue.value = 4323
hidFlag.value ="True"
End Sub


Yes this works, but its not a good way of doing it, with this i will keep the client PC checking on the flag always.

if there is no other way then i will be forced to use it.

But thank you for the help, you code give me many ideas... Thanks


It works fine for me too! I just need to create as many hidden values as the number of parameters.

Thanks.


azuomar:

Yes this works, but its not a good way of doing it, with this i will keep the client PC checking on the flag always.

if there is no other way then i will be forced to use it.

But thank you for the help, you code give me many ideas... Thanks

I knew it's not the best way. However, you could declare a handle variable returned from method "setInterval" and dispose it in method "Open()".


Thanks

Hi,

hope the follwoing will help without setting up the any client side flags :)

string

openPopupJS ="openpopup();";

ClientScript.RegisterStartupScript(

this.GetType(),"openPopupJS", openPopupJS,true);

Cheers,

venky

ajax and webservices...

I have created a dataset. Each method of the tableadapter shows the right data when I preview it at design time.
However, when I load the page I get the value in both dropdownlists: [method error 500]

If I step throught the code, the webmethod is not hit even though I put a breakpoint on it (or is that normal?)

Here's my code:


.ASPX

<asp:DropDownList ID="ddlCountry1" runat="server">
</asp:DropDownList>
<asp:DropDownList ID="ddlLocalCity" runat="server">
</asp:DropDownList>

<cc1:CascadingDropDown ID="CascadingDropDown1"
runat="server"
TargetControlID="ddlCountry1"
Category="CountryName"
prompttext="Select country"
ServicePath="LocalCities.asmx"
ServiceMethod="GetCountries">
</cc1:CascadingDropDown>
<cc1:CascadingDropDown ID="CascadingDropDown2"
runat="server"
TargetControlID="ddlLocalCity"
Category="CityName"
prompttext="Select city"
ServicePath="LocalCities.asmx"
ServiceMethod="GetCitiesForCountry"
LoadingText="Loading...">
</cc1:CascadingDropDown>

Local.vb

<WebMethod()> _
Public Function GetCountries(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()
Dim countryAdapter As CountryMainCitiesTableAdapters.CountriesTableAdapter = New CountryMainCitiesTableAdapters.CountriesTableAdapter
Dim countries As CountryMainCities.tblCountriesDataTable = countryAdapter.GetData
Dim values As New List(Of CascadingDropDownNameValue)
For Each dr As DataRow In countries
Dim CountryName As String = CType(dr("CountryName"), String)
Dim countryId As Integer = CType(dr("CountryID"), Integer)
values.Add(New CascadingDropDownNameValue(CountryName, countryId.ToString))
Next
Return values.ToArray
End Function

<WebMethod()> _
Public Function GetCitiesForCountry(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()
Dim kv As StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)
Dim countryId As Integer
If (Not kv.ContainsKey("CountryID") _
OrElse Not Int32.TryParse(kv("CountryID"), countryId)) Then
Return Nothing
End If
Dim cityAdapter As New DataTable

Dim adapter As CountryMainCitiesTableAdapters.CountryMainCitiesTableAdapter = New CountryMainCitiesTableAdapters.CountryMainCitiesTableAdapter
Dim cityTable As CountryMainCities.tblCountryMainCitiesDataTable = adapter.GetDataByCountryID(countryId)
Dim values As New List(Of CascadingDropDownNameValue)
For Each dr As DataRow In cityTable
values.Add(New CascadingDropDownNameValue(CType(dr("CityName"), String), dr("CityID").ToString))
Next
Return values.ToArray
End Function

Try to follow up the following suggestions to fix the famous Method Error 500 for reference.
1.Try to read this thread -http://forums.asp.net/1476672/ShowThread.aspx#1476672
2.Try to write a web method in behind code to call web service as the following
???Country:<asp:DropDownList ID="ddlCountry" runat="server">
???</asp:DropDownList>
???<AjaxControls:CascadingDropDown ID="CascadingDropDown1" runat="server" TargetControlID="ddlCountry" Category="Country" ????LoadingText="Loading....." ServiceMethod="GetCountries" BehaviorID="CascadingDropDown1" PromptText="- select country -">
???</AjaxControls:CascadingDropDown
???[WebMethod]
???[ScriptMethod]
???public CascadingDropDownNameValue[] GetCountries()
???{
???????WebService ws = new WebService();
???????return ws.GetCountries();
???}
Wish the above can help you.

The other thread did not help me a lot. But I changed some code, however I still receive the error [method 500]

and if I add the attribute
ServicePath="default.aspx.vb" to CascadingDropDown2 I receive the error [method 404]

The code-behind method GetCitiesForCountry is never hit...

DEFAULT.ASPX

<asp:DropDownList ID="ddlCountry1" runat="server">
</asp:DropDownList>
<asp:DropDownList ID="ddlLocalCity" runat="server">
</asp:DropDownList>

<cc1:CascadingDropDown ID="CascadingDropDown1"
runat="server"
TargetControlID="ddlCountry1"
Category="CountryID"
prompttext="Select country"
ServicePath="LocalCities.asmx"
ServiceMethod="GetCountries">
</cc1:CascadingDropDown>
<cc1:CascadingDropDown ID="CascadingDropDown2"
runat="server"
TargetControlID="ddlLocalCity"
ParentControlID="ddlCountry1"
Category="CityID"
prompttext="Select city"
ServicePath="default.aspx.vb"
ServiceMethod="GetCitiesForCountry"
LoadingText="Loading...">
</cc1:CascadingDropDown>

DEFAULT.ASPX.VB

<WebMethod(), Microsoft.Web.Script.Services.ScriptMethod()> _
Public Function GetCitiesForCountry(ByVal knownCategoryValues As String, ByVal category As String) As CascadingDropDownNameValue()
Dim kv As StringDictionary = CascadingDropDown.ParseKnownCategoryValuesString(knownCategoryValues)
Dim CountryID As Integer
If (Not kv.ContainsKey("CountryID") _
OrElse Not Int32.TryParse(kv("CountryID"), CountryID)) Then
GlobalFunctions.ReportError("CountryID: ", "WHOOPS")
Return Nothing
End If
GlobalFunctions.ReportError("CountryID: ", CountryID.ToString)
Dim cityadapter As CountryMainCitiesTableAdapters.CountryMainCitiesTableAdapter = New CountryMainCitiesTableAdapters.CountryMainCitiesTableAdapter
Dim cities As CountryMainCities.tblCountryMainCitiesDataTable = cityadapter.GetDataByCountryID(CountryID)
Dim values As New List(Of CascadingDropDownNameValue)
For Each dr As DataRow In cities
GlobalFunctions.ReportError("CityID: ", dr("CityID").ToString)
values.Add(New CascadingDropDownNameValue(CType(dr("CityName"), String), dr("CityID").ToString))
Next
Return values.ToArray
End Function

Saturday, March 24, 2012

Ajax And Web Reference

hi

is it possible to refer by web service to my ajax control library component AutoCompleteExtender1, if i add asmx page directly to project solution i'm able to give the service path and service method to this component.

i have a separate web service running which is communicating with my SQL Server 2000

so in my solution i added the webservice using add App_WebReferences, sohow to assign my service path and service method to the extender.

thanks in advance.

happy dotnetting.

bye

jags

Hi jags,

It isn't possible to connect to an external webservice. So one solution is. Create a webservice (WebserviceA) within your solution where your website resides. In the code for WebserviceA you make a connection (webreference like you are used to) to WebserviceB (which is outside your domain). Al the requests that are going to webserviceA are passed through to webserviceB which will return the value to webserviceA and webserviceA will return it to your browser. Hope this helps!

Regards,


thanks dennis, i'll be travelling for the next few days.i'll try this and will get back to you at the earliest.