Saturday, March 24, 2012

MyNamespace.MyWebService has no properties error helpp!

Hi all, i have been having trouble getting this to work: Im using masterpages, i set the web reference on the scriptmanager in the masterpage, and the scripreference on the content page, also have a modalpoup IN the content page, a link button in a gridview template and on the clik event (kind of) i call the jscript function to show the modal and execute the webservice(shown below)

HAve a Webservice, that doas a sql query to get certain values from a database:

1using System;2using System.Web;3using System.Collections;4using System.Web.Services;5using System.Web.Services.Protocols;6using System.Web.Script.Services;7using System;8using AjaxControlToolkit;9using System.Data;10using System.Data.SqlClient;11using System.Collections;12using System.Collections.Generic;13using System.Collections.Specialized;1415/// <summary>16/// Summary description for CargarDatos17/// </summary>18[WebService(Namespace ="http://tempuri.org/")]19[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]20[ScriptService]21public class CargarDatos : System.Web.Services.WebService {2223//public CargarDatos () {2425 // //Uncomment the following line if using designed components26 // //InitializeComponent();27 //}2829 [WebMethod()]30 [ScriptMethod()]31 public string GetDynamicContent(string ID_Cliente)32 {33 System.Data.SqlClient.SqlConnection Conn1 = new System.Data.SqlClient.SqlConnection("Data Source=DESKTOP;Initial Catalog=Encuestas;User ID=sa;Password=lf654");34 System.Data.SqlClient.SqlDataAdapter da1 = new System.Data.SqlClient.SqlDataAdapter("SELECT Nombre FROM Clientes WHERE ID_Cliente=@dotnet.itags.org.ID_Cliente", Conn1);35//System.Data.SqlClient.SqlCommand Cmnd = new System.Data.SqlClient.SqlCommand();36 //Cmnd.CommandText = "SELECT Nombre FROM Clientes WHERE ID_Cliente=@dotnet.itags.org.ID_Cliente";37 //Cmnd.Connection = Conn1;38 System.Data.DataSet ds = new System.Data.DataSet();39 try40 {41 da1.SelectCommand.Parameters.AddWithValue("@dotnet.itags.org.ID_Cliente",int.Parse(ID_Cliente));42 Conn1.Open();43 da1.SelectCommand.ExecuteNonQuery();44 da1.Fill(ds);45 Conn1.Close();46return ds.GetXml();47 }48catch (Exception ex)49 {50 Console.WriteLine(ex.Message);51return null;52 }53 }5455}

A Java script function that calls that web service (or at least try:P)

function ShowMyModalPopup(customerid){ var modal = $find('ModalPopupExtender1');

modal.show();

"http://tempuri.org/".CargarDatos.GetDynamicContent(customerid,DisplayResult);

 }

used to show a modalpopup and to pass on values to the web service, and if it works to call another jscript function to populate texboxes in the modalpopup panel.

Have 2 problems: im using firebug to debug client side, and its says to me: "http://tempuri.org/".CargarDatos has no properties...

i get this on the jsdebug:

var CargarDatos=function() {

2CargarDatos.initializeBase(this);

3this._timeout = 0;

4this._userContext = null;

5this._succeeded = null;

6this._failed = null;

7}

8CargarDatos.prototype={

9GetDynamicContent:function(ID_Cliente,succeededCallback, failedCallback, userContext) {

10returnthis._invoke(CargarDatos.get_path(),'GetDynamicContent',false,{ID_Cliente:ID_Cliente},succeededCallback,failedCallback,userContext);}}

11CargarDatos.registerClass('CargarDatos',Sys.Net.WebServiceProxy);

12CargarDatos._staticInstance = new CargarDatos();

13CargarDatos.set_path = function(value) {

14vare = Function._validateParams(arguments, [{name: 'path', type:String}]); if (e) throw e; CargarDatos._staticInstance._path = value; }

15CargarDatos.get_path = function() { return CargarDatos._staticInstance._path; }

16CargarDatos.set_timeout= function(value) { var e = Function._validateParams(arguments, [{name:'timeout', type: Number}]); if (e) throw e; if (value < 0) { throwError.argumentOutOfRange('value', value, Sys.Res.invalidTimeout); }

17CargarDatos._staticInstance._timeout = value; }

18CargarDatos.get_timeout = function() {

19return CargarDatos._staticInstance._timeout; }

20CargarDatos.set_defaultUserContext = function(value) {

21CargarDatos._staticInstance._userContext = value; }

22CargarDatos.get_defaultUserContext = function() {

23return CargarDatos._staticInstance._userContext; }

24CargarDatos.set_defaultSucceededCallback = function(value) {

25vare = Function._validateParams(arguments, [{name:'defaultSucceededCallback', type: Function}]); if (e) throw e;CargarDatos._staticInstance._succeeded = value; }

26CargarDatos.get_defaultSucceededCallback = function() {

27return CargarDatos._staticInstance._succeeded; }

28CargarDatos.set_defaultFailedCallback = function(value) {

29vare = Function._validateParams(arguments, [{name:'defaultFailedCallback', type: Function}]); if (e) throw e;CargarDatos._staticInstance._failed = value; }

30CargarDatos.get_defaultFailedCallback = function() {

31return CargarDatos._staticInstance._failed; }

32CargarDatos.set_path("/sovi1/CargarDatos.asmx");

33CargarDatos.GetDynamicContent=function(ID_Cliente,onSuccess,onFailed,userContext){CargarDatos._staticInstance.GetDynamicContent(ID_Cliente,onSuccess,onFailed,userContext);}

For the type of info there, i assume that it finds the web service, and i can see the method name there, so that should mean that im accesing the WS, but i still dont get why it fails, i never used jscript before neither web services, so its all new to me... so if anyone could point me in the right direction ill be more than gratefull.

Also, im having a Nullreference when i try to invoke the .show method from modalpopup, could this mean that im not finding the modalpopup control?

Plz i have been stuck at this point for over 4 days now.

Tnks in advance.


hi, you just need to drop the http://tempuri.org/" bit from the callback method name, so the method call would be CargarDatos.GetDynamicContent(customerid,DisplayResult);

Cheers Si


Tnks a millon man, it worked!! BUT for a reason... i previously had it that way, and i get the "web service not found error", this was while i was having both, the service reference and the script reference in a scriptmanagerproxy in a content page, i moved those references to a scriptmanager in the master page and then i was hable to find the web service (Mynamespace.mywebservice) but i was getting the above error. Now. i have all the references in the master page, and without the "MyNamespace" i got(U did actuallyStick out tongue) the web service to work.

So the web service issue its fixed, but im still having the modalpopup error, saying that has null on it, i also tryed using:

var modal=document.getElementById('<%=ModalPopupExtender1.ClientID%>');

and still no luck, the modal its on a content page inside a template field in a gridview, if someone can give me a clue on this than it′ll be a completely solved issue.

Tnks again for the rsponse dj Big Smile


No worries dude,

In respsone to your modalpopup problem

var modal=document.getElementById('<%=ModalPopupExtender1.ClientID%>');

This line will not work with the .show() method as it is trying to reference a DOM object not the modalpopup "Behavior" which controls a DOM element. It is the behavior that contains the .show() method. You were correct with this line
var modal = $find('ModalPopupExtender1');

But i'm guessing 'ModalPopupExtender1'is the wrong ID. I guessing if you use $find('<%=ModalPopupExtender1.ClientID%>') this might work, otherwise a quick and dirty way is to view source and look for a line like this(this is from the toolkit samples)

$create(AjaxControlToolkit.ModalPopupBehavior, {"BackgroundCssClass":"modalBackground","DropShadow":true,"PopupControlID":"ctl00_SampleContent_programmaticPopup","PopupDragHandleControlID":"ctl00_SampleContent_programmaticPopupDragHandle","dynamicServicePath":"/AJAX/AjaxControlToolkit/Samples/ModalPopup/ModalPopup.aspx","id":"programmaticModalPopupBehavior","repositionMode":2}, null, null, $get("ctl00_SampleContent_hiddenTargetControlForModalPopup"));

look for this property "id":"programmaticModalPopupBehavior" to find the ID you need to use in the $find() method, in this case it would be $find("programmaticModalPopupBehavior")

Cheers Si


Hi again... as before, u where right on that one too, i was hable to find the modalpopup using the behaviorIDBig Smile, and i need ur wisdom another time to finally get this thing to work, and also ill share a little revelation i had(im sounding like agent Smith...)anyway...im having a lot of trouble finding the textboxes to fill with my jscript function i tryed all this:

document.getElementById('ctl00_ContentPlaceHolder1_TxBxNombreCliente').value=xmlvalue;
document.getElementById('TxBxNombreCliente').value=xmlvalue;
document.getElementById('<%=ContentPlaceHolder1.TxBxNombreCliente.ClientID%>').value=xmlvalue;
document.getElementById('ContentPlaceHolder1.TxBxNombreCliente').value=xmlvalue;
$find('TxBxNombreCliente').value=xmlvalue;
$find('<%=TxBxNombreCliente.ClientID%>').value=xmlvalue;

and absolutely none worked (im trying to set a texbox value).

My revelation its the next... have a masterpage and a few contentpages the thing its that i needit to pass on some values from a content page to another, so i used the Server.Transfer("page2.aspx") on the source page, and virtual path and context.handler on the destination page, being in that one where i was invoking my javascript... and i realized that when y pass on from one webform to the other... the url didnt change so im seeing the content of page2... with the url of page1... so i moved the modalpopup panel to page 1... and was hable to get the thing to work using the

document.getElementById('ctl00_ContentPlaceHolder1_TxBxNombreCliente').value=xmlvalue;

VERY weird... but.. i dont want to use this solution... i want to be hable to find the textbox correcty (also tryed all the above options and none but this one worked)... im clueless by now... u have any idea to share?

Tnks again for the modalpopup thingBig Smile

Farewell

Leandro


HI all again... ill response myself on this matter, cause i was hable to find its solution.

After a lot(A LOT) of testing i manage to locate the control i was searching wothout using the $100_etc_etc_etcMyControl, how? i decided to stop using an external jscript file, and i embbeded the jscript whitin the content tags of the content page, then.. and ONLY then, i could find the textbox using the document.getElementById('<%=TxBxNombreCliente.ClientID%>').value=xmlvalue;

BUT i still cant do it from an external jscript file.... hope that this helps someone else with my same trouble.

Best regards and thns for all...See you all people soonStick out tongue


Farewell

No comments:

Post a Comment