Showing posts with label run. Show all posts
Showing posts with label run. Show all posts

Monday, March 26, 2012

Cause a JavaScript Function to run after update (update panel postback)

Hello,

I ran into a problem that im not sure if the Atlas framework addresses.

I need to fire off a javascript function (which is decided server side)on a postback. To do this I am going to be using a hidden input field.(since I already have one on the form I use to send information forserver use.) From the server side, I can place the function names intothe hidden input field. But I can't cause them to run, on each postback.

I suppose that is confusing, let me try something simpler.

1. I fire off a postback in javascript - This is done using the__dopostback() and the server side fires off its if statements and doesits functions based on what has been placed into my hidden input field.(this is all good so far) (if I had to I could use the body's on formload ability to fire off the javascript functions I desire, but thatwont work for the next step, and is really ugly)

2. I include Atlas to make my postback not refresh the whole page. This is done by using UpdatePanels.

3. On the server side I need to somehow tell it to run certainjavascript functions when that postback finishes loading. (so like onpartial page load)

How do I do step 3?<script type="text/javascript">
function AfterPostback()
{
alert("This is where we check the hidden input and run the functions.");
}

function PageRequestManagerPropertyChanged(sender, args)
{
if (args.get_propertyName() == "inPostBack")
{
if (!$object("_PageRequestManager").get_inPostBack())
AfterPostback();
}
}

function pageLoad()
{
$object("_PageRequestManager").propertyChanged.add(PageRequestManagerPropertyChanged);
}
</script
<div>
<atlas:ScriptManagerEnablePartialRendering="true" ID="ScriptManager1" runat="server">
</atlas:ScriptManager>
<atlas:UpdatePanel runat="server" Mode="Conditional" ID="UpdatePanel1">
<ContentTemplate>
<%= DateTime.Now.ToLongTimeString() %>
</ContentTemplate>
<Triggers>
<atlas:ControlEventTrigger ControlID="UpdateTime" EventName="Click"/>
</Triggers>
</atlas:UpdatePanel>
<asp:Button ID="UpdateTime" runat="server" Text="Update Time" />
</div
Thats the solution I rigged up.
Hi,

Thanks for posting your solution. It works very well and solves a whole bunch of missing stuff with AtlasPanels. One problem dough. I had to move the call to JS function pageLoad() to the end of the html file part instead of putting it to body onload event.
Another option for doing this is theUpdateProgressSignup extension.

Wednesday, March 21, 2012

CascadingDropDown Sample problem, Method Error 500

Hi

I've downloaded the last version of Control Toolkit and I've installed it. When I try to run the WebSampleSite, everything works fine except CascadingDropDown, The first combo says "Method Error 500". Any ideas?

Please help...

to me Method Error 500 is webservices error

try look webservices area..make sure it gets call (you can debug into it)

CascadingDropDown Javascript error "Access is Denied."

Hi All,

I am trying to use the CascadingDropDown control from the AJAX Toolkit, but I recieve a Javascript "Access is Denied." error when I run the page. Googling off and on for the past couple of days hasn't yielded many possible solutions. The only one that looked promising washere but it didn't work in my case. The one piece thats different in my code than the examples I've found is that I'm trying to use an external Web Service/Method. The examples I've found all contain the .asmx file in the same project as the CascadingDropDown.

Information Regarding the Error
File: MicroSoftAjax.debug.js
Line: 4079
Code: this._xmlHttpRequest.open(verb, this._webRequest.getResolvedUrl(), true );
The page has a disabled DropDownList with the text "Loading States..." in it.

ASPX Code

 <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> <Services> <asp:ServiceReference Path="http://l3y9ypb1/IDSWebService/IDSCommon.asmx" /> </Services> </asp:ScriptManager> <ajax:CascadingDropDown ID="CascadingDropDown1" runat="server" Category="Town" LoadingText="Loading states..." PromptText="Select a state..." ServiceMethod="getCDDTowns" ServicePath="http://l3y9ypb1/IDSWebService/IDSCommon.asmx" TargetControlID="DropDownList1"> </ajax:CascadingDropDown> <asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList> </div> </form>

Web Service Code - This Web Method works properly. The only reason I'm posting it is to make sure I didn't make any mistakes with the Service/Method attributes.

using AjaxControlToolkit;using IDSUtility;using System;using System.Collections.Generic;using System.Collections.Specialized;using System.Data;using System.Web;using System.Web.Script.Services;using System.Web.Services;using System.Web.Services.Protocols;[System.Web.Script.Services.ScriptService()][WebService(Namespace = 'http://tempuri.org/')][WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]public class IDSCommon : System.Web.Services.WebService{public IDSCommon() { } [ScriptMethod] [WebMethod]public CascadingDropDownNameValue[] getCDDTowns(string knownCategoryValues,string category) {string districtCode ="05";return Utility.getCDDVArrayFromDataTable(Utility.getDataTableFromStoredProcedure("districtCode", districtCode,"cursorTowns","getTowns","TOWNS"),"TOWN_NAME","TOWN_CODE"); }}

I'd appreciate any information regarding this problem.

Thanks,
Andy

I think you may be hitting cross-domain limitations that are outlined here and in the linked article discussing a related issue:http://blogs.msdn.com/delay/archive/2007/02/05/safely-avoiding-the-access-denied-dialog-how-to-work-around-the-access-denied-cross-domain-iframe-issue-in-the-ajax-control-toolkit.aspx


Hi Andy,

XmlHttpRequest doesn't support cross domain posting, so you can't use a web service in a different domain.

You may solve it by adding a proxy web service in the same domain, and this web service simply expose a serials of methods similar to the remote web service's. It internally calls the remote web service to implement.

On your page, register the web service within the same domain instead.

Hope this helps.


Thank you very much, that did the trick!