Showing posts with label method. Show all posts
Showing posts with label method. Show all posts

Wednesday, March 28, 2012

Vertical tabs

I posted on in the toolkit forum but thought I would widen the audience a bit.

What's the best method these days for creating vertical tabs? I currently use the toolkit's tab control for my horizontal tabs but I want to put it in another tabcontainer that has vertical tabs (kinda like an old style TV set with channels as buttons). How are people doing this these days? Doesn't look like the AJAX tab control can be made into vertical tabs and after googling around I didn't see anything that jumped out at me.

Thoughts?

Thanks!

Craig

Hello craigcl,

I didn't see the implementation of this, but consider reading this article
http://www.codeproject.com/aspnet/WebTabControl.asp?df=100&forumid=304531&exp=0&select=1758008
and downloading the AJAX Toolkit sources helps your to create your own vertical
tabs

c> I posted on in the toolkit forum but thought I would widen the
c> audience a bit.
c>
c> What's the best method these days for creating vertical tabs? I
c> currently use the toolkit's tab control for my horizontal tabs but I
c> want to put it in another tabcontainer that has vertical tabs (kinda
c> like an old style TV set with channels as buttons). How are people
c> doing this these days? Doesn't look like the AJAX tab control can be
c> made into vertical tabs and after googling around I didn't see
c> anything that jumped out at me.
c>
c> Thoughts?
c>
c> Thanks!
c>
c> Craig
c>

It doesn't do this out of the box, but you can customize the AJAX Control Toolkit's tab control to do this. If you look at the tab's source, you'll see it renders just simple SPANs and DIVs. You can get a bit more insight on what is happening if you look atmy blog post on styling the tabs.

Hope this helps.

-Damien

Vertical tabs

What's the best method these days for creating vertical tabs? I currently use the toolkit's tab control for my horizontal tabs but I want to put it in another tabcontainer that has vertical tabs (kinda like an old style TV set with channels as buttons). How are people doing this these days? Doesn't look like the AJAX tab control can be made into vertical tabs and after googling around I didn't see anything that jumped out at me.

Thoughts?

Thanks!

Craig

Hi Craig,

Currently, there isn't a easy way to customize the tab control to show tabs vertically. But I don't think is quite difficult to implement your own one.

1. You may place several buttons vertically on the page.

2. Add some panels with corresponding content in them

3. Add javascript to control the visibility of these panels within the client side click handler of buttons

Very Basic Static Method Question - SlideShowExtender

I'm working with the SlideShowExtender to show slides from a database. I have everything working as planned, except for a major oversight which I can't figure out how to get around properly. Internally I am housing a static SlideList object which contains all the slides returned from my DAL. Inside my

static AjaxControlTookit.Slide[] GetSlides() method I am copying the SlideList interal objects into the Slide[] object and then returning it. Now for my problem, naturally because my SlideList is static, there is only one copy across each page. When more than one user is on the website at the same time, obviously they are touching the same slideshow data which is causing a lot of problems. What is the correct way to handle this solution? Was I supposed to place the GetSlides() method in a WebService.asmx webservice, or is it ok to keep them as PageMethods and then correctly keep track of the Slides on a per page basis?

I would rather keep the GetSlides() method as a static PageMethod so I don't have to completely refactor the entire project, however I am not sure how I would correctly go about having Slides and then accessing them within my static methods. I realize this is a very elementary problem, and I feel awfully silly for not knowing the answer!

THanks!

Hi,

Your question is how to return different slides upon different requests, isn't it?

Well, you may pass a parameter (contextKey) into the GetSlides method, and use it to filter some slides.

For example, let's say you plan to filter the slides according to the userName of the one is browsing the page, you assign current user name in Page_Load.

protected void Page_Load(object sender, EventArgs e)
{
this.slideshowextend1.ContextKey = currentUserName;
}

[System.Web.Services.WebMethod]
[System.Web.Script.Services.ScriptMethod]
public static AjaxControlToolkit.Slide[] GetSlides(string contextKey)
{ // return a slide array according to contextKey
}

Hope this helps.

Wednesday, March 21, 2012

Web Method Caching

When caching is enabled in a web method, ASP.NET Ajax Extensions set theCacheabilityof theResponse.Cache object toServer. The problem is that the network overhead is still incurred when making a call from JavaScript. Further, as theCacheability is already set toHttpCacheability.Server before the method is called, it is not possible to override it with any other value exceptHttpCacheability.NoCahe. This means that there is no way to implement browser side caching with ASP.NET Ajax web services. This seems to be a pretty stringent rule or am I missing something very obvious?

All I want to do is to save the browser from incurring a network overhead when calling web services. Currently, I have resorted to JavaScript code to do the caching. But it will be nice if web methods can also be cached by the browser.

Hi Rama Krishna,

Take a look at this blog:

http://msmvps.com/blogs/omar/archive/2006/09/23/Atlas-7_3A00_-Caching-web-service-response-on-browser-and-save-bandwidth-significantly.aspx

HTH

Regards,


I have seen that solution, but I don't like the idea of reflection to set the max age as it does not work in medium trust.

web method error in cascadingDropdown

i am trying to use the cascading dropdownlist control, using a web service to get items from a database. the web method works fine, but i get a web method error 404 or 500. any help in solving this would be greatly appreciated.

Hi, mnyats.

I solved right now (telling the true, in this exact minute) a problem I was facing that was generating this same error message. In my case the problem was:

1 - I was trying to make cascadingDropDown to work with no service; (I guess it's possible but all the samples I got on the web says no)

2 - On the call of my service, inside my aspx page, I forgot to include the full namespace of the service;

3 - The service was with the attribute: <System.Web.Script.Services.ScriptService()> commented.

I don't know which problem are you having now, but I hope this can help...

See you!@.!

<mnyats> escreveu na mensagemnews:1966118@.forums.asp.net...

i am trying to use the cascading dropdownlist control, using a web service to get items from a database. the web method works fine, but i get a web method error 404 or 500. any help in solving this would be greatly appreciated.

http://forums.asp.net/p/1172554/1966118.aspx#1966118


Hi,

I think Fiddler is a good choice for you to trouble shooting. Please refer to this thread: http://forums.asp.net/t/1172379.aspx

Web Methodst that returns DataTable gives me exception error " "circular reference was det

Hello,

I am getting this error "circular reference was detected while serializing an object of type". The Method GetRecords() is a function that returns DataTable type.. It happens the same thing when i return DataSet as well.

Any help?

Thanks

function GetStatusRecord() {

// Invoke the Echo method on the server.

PageMethods.GetRecords('1', onComplete);

debugger;

// Callback function.

function onComplete(result) {

// Display the echoed string.

alert(result);

}

returnfalse

}

The latest version of Asp.net Ajax no longer allows to serialize DataTable and DataSet anymore.


you are probably right, i havent updated asp.net ajax for about 6 months.

Web Service - Invoking on remote server and scheduling

Hello,

I created a web service on my local computer. This web service has one Web Method, which I can [INVOKE] the method by pressing a button on my local computer ie->http://localhost:2234/mywebservice.asmx. However, when I upload this webservice to my remote account at easycgi, the [INVOKE] is missing.

My question is why is the [INVOKE] button missing?
Do I need to create a proxy using WSDL in order to run my web method?
Also, does anyone know how to schedule a web service to run at specified times, if you do not have access to the host server?

Thanks,

-Robert

Hello,

I am going to answer my own question here. I was able to set up a proxy by creating a web reference to my webservice in vs2005. Using the proxy I called my web service method. I am still not sure why the [INVOKE] button was missing on my .asmx file when I uploaded, but no matter.

My web host provider, easycgi, provides a script scheduler. The script can be an .aspx that runs code on the page load event. By calling my web service method on page load event I am able to call my web service at specified times.

-Robert


Gratz on sorting it out Robert

A security feature of WebServices is that the invoke option will only appear on local webservices. There is a security setting you can add to the web.config to allow this remotely but i can't remember what is was. It was a VS2003 feature as i recall and it's likely been removed since .net 2.0

I could probably dig it out though if you need, let me know. It can be handy to check a remote service via the browser

Web Service and Custom Type(Enumeration)

Hello,

I have a web service with a method called "Login" Login returns a custom enumeration type called "MethodStatus". I am trying to call this method in Atlas, my client code is below

 function OnbuttonGo_click() { //Call script proxy passing the input element data var object = Crisp.ParentWebService.MainService.Login( 'd','d', //params OnComplete, //Complete event OnTimeout //Timeout event ); return false; } function OnComplete(result) { alert(result); } function OnTimeout(result) { alert("Timed out"); }
This method works fine if I change the type in my Login status to String but when I use my enumeration it fails
giving me the following error message:
Key cannot be null.
Parameter name: key
Server Error in '/AtlasWebSite1' Application.
Key cannot be null.
Parameter name: key
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.ArgumentNullException: Key cannot be null.
Parameter name: key
Source Error:
An unhandled exception was generated during the execution of the current
web request. Information regarding the origin and location of the
exception can be identified using the exception stack trace below.
Stack Trace:
[ArgumentNullException: Key cannot be null.
Parameter name: key]
System.Collections.Hashtable.ContainsKey(Object key) +2773989
System.Collections.Hashtable.Contains(Object key) +4
Microsoft.Web.Services.ClientProxyGenerator.EnsureNamespace(Type t) +46
Microsoft.Web.Services.ClientProxyGenerator.GenerateEnumTypeProxies(IEnumerable`1 enumTypes) +117
Microsoft.Web.Services.ClientProxyGenerator.GetClientProxyScript(WebServiceData webServiceData) +339
Microsoft.Web.Services.WebServiceClientProxyGenerator.GetClientProxyScript(HttpContext context) +263
Microsoft.Web.Services.RestClientProxyHandler.ProcessRequest(HttpContext context) +79
Microsoft.Web.Services.HandlerWrapper.ProcessRequest(HttpContext context) +30
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +401
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +117
Version Information: Microsoft .NET Framework Version:2.0.50727.42; ASP.NET Version:2.0.50727.42
     <!--
[ArgumentNullException]: Key cannot be null.
Parameter name: key
at System.Collections.Hashtable.ContainsKey(Object key)
at System.Collections.Hashtable.Contains(Object key)
at Microsoft.Web.Services.ClientProxyGenerator.EnsureNamespace(Type t)
at Microsoft.Web.Services.ClientProxyGenerator.GenerateEnumTypeProxies(IEnumerable`1 enumTypes)
at Microsoft.Web.Services.ClientProxyGenerator.GetClientProxyScript(WebServiceData webServiceData)
at Microsoft.Web.Services.WebServiceClientProxyGenerator.GetClientProxyScript(HttpContext context)
at Microsoft.Web.Services.RestClientProxyHa

You're doing something else wrong somewhere, and I don't know from your code what it is. I just did the part that you think is tripping you up, and it works fine. Code follows:

<... Html stuff that builds a pair of text boxes and a button ...>

<script type="text/javascript">

function button_Click()

{

var name = document.getElementById("userName");

var pass = document.getElementById("passWord");

requestService = TestEnums.MyService.Login(

name.value, pass.value

OnComplete,

OnTimeOut);

return false;

}

function OnComplete(result)

{

alert(result);

}

function OnTimeOut(result)

{

alert('timed out');

}

</script>

<... closing html stuff ...>

now the web service

<... web service header, using statements, and so on ...>

[WebMethod]

public Status Login(string a, string b)

{

if(a==b)

return Status.Authenticated;

else

return Status.Anonymous;

}

<.... Enum ...>

publuic enum Status

{

Anonymous,

Authenticated

}

Now, what happens is that the thing runs, and it alerts 0 or 1. I suspect you'd have to handle the enum in javascript as well in order to translate the enumeration into something meaningful on the client. But the bottom line is that passing a custom type is not error-generating action.


Hello,

I have fixed the problem now the problem was because I never set a namespace for the enumeration. I had set a namespace for my service and not for my enumeration.

Thank's alot for your help!

Rob


No problem, glad you found it!

Web service class undefined on Client load

Having tested a simple atlas web method call from the client which is fired by calling a javascript function on a button client side click event -it works perfectly.

The problem is I need this function called when the page loads, however whenever calling this function from either the body onload client side event or by using the RegisterStratupScript on the server side page load method, I get a javascript error refering to the web service class name as being undefined.

In theory this should work, Am I missing something regarding my understanding of the atlas lifecycle perhaps?

Please help!
Thanks

Dynamic script references (included in the References section of the ScriptManager) are not available until after page loading. To use these, you need to hook the Load event of the Application object. Declaratively, you can do this with:

<application>

<load>

<invokeMethod method="MyMethodName" />

</load>

</application>

Alternatively, you can statically include the service with a <script> tag.


A simpler syntax to do this is to have:

<application load="OnApplicationLoad" />

This goes into your <components>. So you would have something like this:

<script type="text/xml-script">
<page xmlns:script="http://schemas.microsoft.com/xml-script/2005">
<references>
</references>
<components>
<application load="OnApplicationLoad" />
</components>
</page>
</script>

David


BTW, I should mention that there is yet an easier way: just name your method pageLoad and it will be automatically called without having to be registered. See theAtlas docs for some examples.

David