Showing posts with label class. Show all posts
Showing posts with label class. Show all posts

Wednesday, March 28, 2012

Profilewebserice path doesnt work under virtual url.

I tried to find a way to replace profilewebservice with my own webservice or class, and then I found a problem. I don;t believe it is happening, but I am not sure what is wrong.

In ATLAS.js, we can find code like

Sys._Profile.WebServicePath = 'ScriptServices/Microsoft/Web/Services/Standard/ProfileWebService.asmx';

see the webservicepath is relative. When I go tohttp://mydomain.com/page/home.aspx, and do Sys.Profile.Load, I get this error:

Parser Error Message:The directive 'Page' is unknown.

Source Error:

Line 1: <%@dotnet.itags.org. Page Language="C#" ValidateRequest="false" ViewStateEncryptionMode="Never" Debug="false" EnableEventValidation="false"Line 2: CompilationMode="Never" Inherits="LinkLibrary.LinkPage" %>


Source File:/page/ScriptServices/Microsoft/Web/Services/Standard/ProfileWebService.asmx Line:1

looks like it add my virtualpath in, that doesn't sound right?

Well, it looks like your web service .asmx file has an @.Page directive in it... no? Which is wrong, if true. That's how it appears to me from what you've posted, anyway.

the asmx is ATLAS asmx.

It shows where the error happens, the @.Page is in my page.


? you said you replaced the prepackaged asmx with your own in your first post. Maybe if you posted your code, it'd be easier to help you debug it?

Oh, that confused you.

What I tried to say is I tried to find a way to use my asmx, but before I found a solution, I found a bug .

What I put on my page is just like this :

Sys.Profile.set_autoSave(false);
Sys.Profile.loaded.add(onProfileLoadComplete);
Sys.Profile.load();

and I got that error, because the test url ishttp://mydomain/page/home.aspx.

It seems the webservice add the page into its webservicepath.

If this is really a bug, I think ATLAS group should fix it. I am not sure why others didn't find it.

Line 1: <%@. Page Language="C#" ValidateRequest="false" ViewStateEncryptionMode="Never" Debug="false" EnableEventValidation="false"Line 2: CompilationMode="Never" Inherits="LinkLibrary.LinkPage" %>


Source File:/page/ScriptServices/Microsoft/Web/Services/Standard/ProfileWebService.asmx Line:1

You can tell from the error message, "ScriptServices/Microsoft/Web/Services/Standard/ProfileWebService.asmx " is what ATLAS defined in its js, but the path doesn't have "/" in front of it, I think that is where the problem from.



Have you tried giving it an absolute url just to test it and see if it's not getting hung up on where to start?


Yes, now I am using my own asmx, I set it with absolute path, it works fine under that url - /page/home.aspx
Glad to hear it!

Programmatic equivalent to System.Web.UI.ScriptResource attribute?

Is there a programmatic equivalent to the following attribute normally put in the AssemblyInfo file in a class library project?

<Assembly: System.Web.UI.ScriptResource("LocalizedControl.TravelInfo.js", "LocalizedControl.TravelResources", "Travel")>

I would like to use reflection to do this programmatically w/o having to link in System.Web.Extensions.

I can use ScriptManager.RegisterClientScriptResource()

to do the equivalent of

<Assembly: System.Web.UI.WebResource("LocalizedControl.TravelInfo.js", "application/x-javascript")>

but have not found a way to do the equivalent of the ScriptResource attribute.

Thanks,
Chris

Hi cpels,

Hope this will helps.

To specify how resource files are managed when an assembly is built, you include attributes in the AssemblyInfo file (AssemblyInfo.vb or AssemblyInfo.cs file).

In ASP.NET, you mark resources for the application by using theWebResourceAttribute class. To embed JavaScript files in an assembly, you use this attribute to specify the .js files as a Web resource.

To include resource files for the embedded JavaScript files, you use theScriptResourceAttribute class that is provided by ASP.NET AJAX. This attribute identifies the files specifically as resources for the JavaScript files.

The following example shows how to use assembly attributes to identify embedded scripts and their associated script resources.

' Indicates that neutral fallback resources are retrieved from ' the main assembly named MainAssembly.<assembly: NeutralResourcesLanguageAttribute("en-US", UltimateResourceFallbackLocation.MainAssembly)>' Defines embedded scripts as Web resources.<assembly:WebResource("Sample.js", "text/javascript")><assembly:WebResource("Sample.debug.js", "text/javascript")>' Defines the script resources for the scripts and their types.<assembly:ScriptResource("Sample.js", "Sample.resources", "Sample.Res")><assembly:ScriptResource("Sample.debug.js", "Sample.debug.resources", "Sample.Res")>

// Indicates that neutral fallback resources are retrieved from // the main assembly named MainAssembly.[assembly: NeutralResourcesLanguageAttribute("en-US", UltimateResourceFallbackLocation.MainAssembly)]// Defines embedded scripts as Web resources.[assembly:WebResource("Sample.js", "text/javascript")][assembly:WebResource("Sample.debug.js", "text/javascript")]// Defines the script resources for the scripts and their types.[assembly:ScriptResource("Sample.js", "Sample.resources", "Sample.Res")][assembly:ScriptResource("Sample.debug.js", "Sample.debug.resources", "Sample.Res")]
 

In this example, a main assembly namedMainAssembly contains an embedded release version of a client script file that is named Sample.js. The assembly also contains the corresponding debug version named Sample.debug.js. The .js files are identified as resources by theWebResourceAttribute attribute.

TheNeutralResourcesLanguageAttribute assembly attribute is used to specify the main assembly as the fallback culture. For more information, seeNeutral Resources Languages for Localization and theNeutralResourcesLanguageAttribute class overview.

The resources used by the script files are defined by using theScriptResourceAttribute attribute. The Sample.resources and Sample.debug.resources files contain resource values for the Sample.js and Sample.debug.js files, respectively.

A type named Sample.Res is generated for both the release and the debug version of the script resources. This is the type that the JavaScript code should use to access localized values. For both release mode and debug mode, the build process creates only a single type. In debug mode the resources for the release version are combined with the additional resources for the debug version.

For more information about how to create assembly-information files and the assembly metadata that is required for versioned assemblies, seeHow to: Create Versioned Assemblies for Precompiled Web Sites.

http://ajax.asp.net/docs/overview/LocalizingResources.aspx
If I misunderstood you,please let me know.
 


I am familiar with how to use the ScriptResourceAttribute in an assembly. However, this requires that the System.Web.Extensions assembly be referenced in the assembly that I am building. What I want to do is NOT have my assembly reference System.Web.Extensions, but rather use reflection to invoke various aspects of MSFT AJAX so there is no dependency on having AJAX installed. This allows my user control in the assembly to work on systems that are not using AJAX if necessary.

I have been able to implement all aspects of my MSFT AJAX functionality this way except the ScriptResourceAttribute. The ScriptManager class has the RegisterClientScriptResource() method. However, the ScriptManager class does not have a method for associating a resource with a client script the way the ScriptResourceAttribute does.

Chris

Programmatically Select a listview item

Can't seem to figure out how to do this. The listview class browser doesn't list much in the way of an API call to do this. Anyone know if this is possible?Did you figure this out?

ListView.SelectedListViewItemCollection listViewItemCollection = this.ListView1.SelectedItems;

foreach ( ListViewItem item in listViewItemCollection)
{
//Your code goes here
}


ListView1.Items(0).Selected = True
ListView1.Select()

The first line indicates what item is to be selected, and the second line is what actually selects it. The most common mistake is leaving out the second line.

Monday, March 26, 2012

Progress Monitor Framework

In the August 2007 edition of Cutting Edge, Dino Esposito created an Ajax progress bar class. Sounded interesting so I downloaded the code, but I'm getting the following odd error on everypage and don't know how to resolve it:

"The 'webServices' start tag on line 67 does not match the end tag of 'scripting'.

I've rechecked that Ajax is properly configured.

Anyone have any ideas?

Hi

"The 'webServices' start tag on line 67 does not match the end tag of 'scripting'.

It seems a coding mistake.

Would you please provide us with any code?

Thanks


HiAlexB1318,

i had the exact same problem and this is due to an code error. I found the corrected code here:http://download.microsoft.com/download/f/2/7/f279e71e-efb0-4155-873d-5554a0608523/MSDNMag2007_08.exe

Proxy Class generated at run time

Greetings,

as i know that the proxy class for the webservice is generated at run time ,but i am not understanding this concept because before i run my application i can access all the members(as methods) of this generated proxy class.

so i need to understand this topic?

your help is highly appreciated

best regards



Hi Wissam,

The proxy class indeed is created at runtime. When i look at my proxy this isn't possible. Are we talking about a javascript proxy?

Regards


Greetings,

i mean the proxy class when you add a web reference to the webservice.


Hi Wissam,

Yep when you create a webreference then you will be able to see the methods. The proxy isn't generated at runtime. The proxy is generated at design time. Hope this helps!

Regards,

Saturday, March 24, 2012

Question about Overriding Methods

Greetings,
I'm having trouble seeing the base class method if I've overriden it...I am not sure what I'm doing wrong. I've tried to study how the Atlas framework is using it, but nothing is working. Here's my code:
Type.registerNamespace("Juicy.Collections");
Juicy.Collections.ArrayList = function() {
var _items = new Array();
this.get_item = function(i) { return _itemsIdea [I]; }
this.get_length = function() { return _items.length; }
this.add = function(item) { _items.add(item); }
this.clear = function() { _items.clear(); }
this.dispose = function() { for (var i = 0; i < _items.length; i++) { _itemsIdea [I].dispose(); _itemsIdea [I] = null; } _items.clear(); }
}
Type.registerClass("Juicy.Collections.ArrayList", null, Web.IDisposable);
Type.registerNamespace("Juicy.UI");
Juicy.UI.TabPageCollection = function(owner) {
Juicy.UI.TabPageCollection.initializeBase(this);
var _owner = owner;
this.add = function(tabPage) { Juicy.UI.TabPageCollection.callBaseMethod(this, "add", tabPage); } // The callBaseMethod always evaluates to null.
Juicy.UI.TabPageCollection.registerBaseMethod(this, "add"); }
Type.registerClass("Juicy.UI.TabPageCollection", Juicy.Collections.ArrayList);
// Code to test the above. The get_length() works fine, but the add does not increment properly.
var tabPages = new Juicy.UI.TabPageCollection();
tabPages.add("foo");
alert(tabPages.get_length());
I want the "add" method in TabPageCollection to do some work, and then call the inherited add. But the callBaseMethod does not resolve.
Any ideas anyone? This is driving me nuts here.
Thanks,
William

I think I found the answer to my question. The base class has to have a call to "registerBaseMethod" for the method that may be overridden.
Just as an idea, wouldn't it be more intuitive for the derived class to have syntax/method indicating that it is overriding the base? I can't off the top of my head think of how this could be done, but it took me awhile to figure out how the current manner works. Perhaps Type.overrideMethod(this, methodName, someFunctionReference).
Thanks,
William

You need to register the base method in the ArrayList class.

Juicy.Collections.ArrayList.registerBaseMethod(this, 'add');

Then your callBaseMethod should start resolving. However, you need to make one more small tweak - the arguments to the base method are passed as an array of arguments. So you would have:

Juicy.UI.TabPageCollection.callBaseMethod(this, 'add', [tabPage]);