Showing posts with label via. Show all posts
Showing posts with label via. Show all posts

Wednesday, March 28, 2012

Calling AJAX function

Hi, I wonder if there's a way to call an AJAX function via code behind page. That is, I have an asp tab control on my page, in which on pressing a tab I open a menu via AJAX code and ask user to enter password then I validate that password and want to select that tab if password is correct. Since my tab is asp control the AJAX code doesn't know that so I have to return the password to the code behind page but since I have to call such function through AJAX:

[Ajax.AjaxMethod(HttpSessionStateRequirement.ReadWrite)]
public void CheckRoomPsw(string psw)
{

...

}

I don't have access to Tab control because this returns null, so there's two options which I don't know how to perform:

1. call an AJAX control from CheckRoomPsw(string psw)

2. get an access to tab control in CheckRoomPsw(string psw)

Any idea is appreciated.

have you tried using the findControl function. it lets you access a conrol by referencing its location and using its ID. so if you had a bunch of controls on your form and wanted to get to one you could do.

form1.findControl("controlIDgoesHere");

if yours is inside of some ajax stuff it might be like

UpdatePanel1.findControl("myControlsID");

then you can just cast that to reference the object type

string value = ((TextBox)form1.findControl("txtUserName")).Text;


Actually, I've done that:

[Ajax.AjaxMethod(HttpSessionStateRequirement.ReadWrite)]
public void CheckRoomPsw(string psw)
{
JQD.TabStrip ts = (JQD.TabStrip)this.FindControl("TabStrip1");
ts.SelectTab(Global.tabPos);
}

but this returns null!!

I think it's because CheckRoomPsw() is an AJAX function


Perform the tab selection on the client-side callback. Return a boolean from the AJAX method after you check the password, if it is true perform the tab selection.


Also, it looks like you're using AJAX.NET, which is a completely separate product from ASP.NET AJAX, so you might want to see if they have a forum.


Have you had luck fixing your issue?

-Damien


Not yet!

I'm still looking for solution!


Have you tried doing the tab selection client-side?


I tried much to get access to the tab control from js code (client side) but since the tab control is an asp user control, it can't be known from js code.


Use theOnClientActiveTabChangedproperty on the tab. Seehttp://asp.net/AJAX/Control-Toolkit/Live/Tabs/Tabs.aspx for more information.

-Damien


Thanks for your concern Domien!

However, I'm not using AJAX.net and don't know much about itEmbarrassed and it's a bit risky to change my tab control now that I'm on the final steps of completing my project

IS there any other solution please

Monday, March 26, 2012

Call to WebService not working...

I am getting this error 'Microsoft JScript runtime error: 'wsWeatherFeed' is undefined. It's just a basic call to a webservice via the asp:ScriptManager tag. Can someone help me point out what I might be doing wrong?

.Aspx file:

<scriptlanguage="javascript"type="text/javascript">

function fnImgMouseOver(e){

wsWeatherFeed.set_timeout(40000);

wsWeatherFeed.fnGetWeatherData(e,callback_fnImgMouseOver,fnGetWeatherDataError);

}

function callback_fnImgMouseOver(result){

alert(result);

}

function fnGetWeatherDataError(err){

alert("Here is the error: " + err.error);

}

</script>

<further down>

<asp:ScriptManagerID="ScriptManager1"runat="server">

<Services>

<asp:ServiceReferencePath="wsWeatherFeed.asmx"/>

</Services>

</asp:ScriptManager>

.Asmx file

<%@dotnet.itags.org.WebServiceLanguage="C#"CodeBehind="~/App_Code/wsWeatherFeed.cs"Class="wsWeatherFeed" %>

.cs WebService file:

using System;

using System.Web;

using System.Web.Services;

using System.Web.Services.Protocols;

using System.Collections;

using System.Xml;

using System.Xml.XPath;

using System.Xml.Xsl;

[WebService(Namespace ="http://tempuri.org/")]

[WebServiceBinding(ConformsTo =WsiProfiles.BasicProfile1_1)]

[System.Web.Script.Services.ScriptService()]

publicclasswsWeatherFeed :WebService {

public wsWeatherFeed () {

//Uncomment the following line if using designed components

//InitializeComponent();

}

[WebMethod]

protectedstring fnGetWeatherData(String strData)

{

return strData

}

}

I got this to work with VB.Net but I guess I just lost something along the way, can anyone provide a clue?

J

Ok I got it. The reason why my js couldnt get to my webservice class was that my web service method fnGetWeatherData was intially set to 'protected' instead of 'public'.

Anyway, I didnt want anyone to spend any time troubleshooting this if I can answer it quick enough myself.

J

Saturday, March 24, 2012

CalendarPopup not showing up over PopupControlExtender

I have a panel that is popped up via a PopupControlExtender and inside that panel I have a CalendarExtender that pops up but it is NOT showing up over top of the PopupControlExtender that is already popped up...How can I force the CalendarExtender to pop up over everything?

Thanks, Greg

I got the calendarExtender to work after I took it out of being contained in a UserControl... There must be something buggy with the CalendarExtedner being in a UserControl??