Showing posts with label custom. Show all posts
Showing posts with label custom. Show all posts

Wednesday, March 28, 2012

Change Object name in generated WSDL

Good day,

I have a Web Method that uses a simple custom object, name Client, as a parameter, and also returns a Client.

However, in the generated WSDL, I want "element name="Client" " to be changed to "element name="THE_CLIENT", but without changing the class name.

Is there a way to specify that an object should have another name in the wsdl, Something like [WebMethod(Description="DESCRIPTION")], but for a class?

Thank you, have a nice day!

Hi,

I think this link provide all information you need:http://msdn2.microsoft.com/en-us/library/2baksw0z.aspx

By default, an XML element name is determined by the class or member name. In a simple class named Book, a field named ISBN will produce an XML element tag <ISBN>, as shown in the following example.

Visual Basic

Copy Code

PublicClass BookPublic ISBNAsStringEndClass' When an instance of the Book class is serialized, it might' produce this XML:' <ISBN>1234567890</ISBN>.

C#

Copy Code

publicclass Book{publicstring ISBN;}// When an instance of the Book class is serialized, it might// produce this XML:// <ISBN>1234567890</ISBN>.

This default behavior can be changed if you want to give the element a new name. The following code shows how an attribute enables this by setting theElementName property of aXmlElementAttribute.

Visual Basic

Copy Code

PublicClass TaxRates < XmlElement(ElementName ="TaxRate")> _Public ReturnTaxRateAsDecimalEndClass

C#

Copy Code

publicclass TaxRates{ [XmlElement(ElementName ="TaxRate")]public decimal ReturnTaxRate;}

For more information about attributes, seeExtending Metadata Using Attributes. For a list of attributes that control XML serialization, seeAttributes That Control XML Serialization.

Best Regards

Monday, March 26, 2012

Cascasding Drop Down Page method custom variable

Hi

I have page method populating the first of my drop downs and the reason being is that i need a variable that will be specific to user.
Currently this is stored in the session...How can i use this variable in the Page Method that is static...I cant really use a static variable as they are shared between all users.

Thanks.

Steve

Hi Steve,

Unfortunately I don't know of a good way to do this anymore. When we first wrote CascadingDropDown page methods weren't required to be static so there was an easy solution. Could you create a work item on CodePlex for this? Perhaps we could modify the web service signature to include optional tag info.

Thanks,
Ted

AAAAAHHHHH!!!!!

Well i have found a solution that works for me and may well for others.....
I have a web method that has Sessions enabled that i can call to get the value from...of course this method cannot be on the page as Sessions arent static.

[

WebMethod(EnableSession =true)]
publicCascadingDropDownNameValue[] GetDivisionsBySessionIdAccount(string knownCategoryValues,string category)
{
SessionCollection oSC; if (Session["UserObj"] !=null) {
oSC = (SessionCollection)Session["UserObj"];
// Calling another method to get my array - the same one i used from the page method.
CascadingDropDownNameValue[] retArray = GetDivisionsByIdAccount(oSC.idAccount);
return retArray;
}
else {
thrownewException("Your Session Has Expired");
}
}

I have created a work item number7579 for this.

---

I have just updated to the release toolkit and now my CCDD have stopped working! The top drop down loads fine from the method above but none of the others below. I have a debug error in jsSys.Debug is null or not an object.??

ARGH!


Here's more on the typical cause of Sys.Debug is null:http://forums.asp.net/thread/1546990.aspx

Saturday, March 24, 2012

CascadingDropDown: Fire an Event

I have created a custom control that contains 3 CascadingDropDown boxes.

I would like to have the control fire a custom event when each of the "TextChanged" or "SelectedIndexChanged" events from the Drop Down items change.

I have added the appropriate "events" into my code behind, but they do not seem to fire. Does the JavaScript intercept them?

Any help would be greatly appreciated.

Thanks,
Bryan

The Changed events you rever to are server-side events that only fire when there's a postback. By design, CascadingDropDown doesn't do postbacks. So you don't get those events when using it. You could force a postback, but doing so would seem to negate many of the benefits of the CDD.

Mr. Anson,

Perhaps you could point me in a better direction for my needs.

The Custom Control that I have created consists of 3 CascadingDropDowns that allow the user to select a Location, Skill, and Supervisor (basically this is like the Make/Model/Color sample for the car.).

My control works fine when I incorporate a button to run a report on a different page. My Button_OnClick event can see what values are in my control, and it will send them to the new page.

I would like to incorporate my current control on a page to help narrow down yet another Drop Down List.

In the CDD example, after the user selects the Make/Model/Color, I would like to pull a list of Vehicles by Year to select.

How would I go about hooking up a new CDD that requires the control to have filled in the Make/Model/Color before it can go out and find it's data?

I thought that I could do something like placing the control and drop down list inside an update panel, but I am a little fuzzy on how to continue from there.

Would I need to set up an Atlas Trigger?

Any help that you can provide would be greatly appreciated. It would even help if you could point me in a better direction.

Thanks, Bryan


Could you add a ByYear CDD that has the Color CDD as its parent? That way it automatically populates when the Make/Model/Color are filled in. And it's welcome to call a completely different web service, so it can get whatever data it wants.

If my Make/Model/Color are in a seperate control, how will I be able to give my Year CDD the parent that is inside the control? Can I just expose the CDD as a public member?

I don't want to add the Year CDD into my control. A different page may want to populate a different CDD from the data that the control provides.


You could manually hook some script up to the "onchanged" event on the client-side select element, but it's probably ultimately the same problem as above with respect to how the Year can see into the control to get the right elements.

CascadingDropDown suggestion

Hi.

Over at CodePlex, I was told to post suggestions here for the community to comment on. So, any comments?

I have a custom control called FirstItemDropDownList that allows you to set the first item to something like "Select an item". That is the text for the dropdown. The value is a GUID that is always the same so that in code I can tell if the selection is still on the first item by the GUID value. The CascadingDropDown extender has a PromptText property to set the "Select an item" text. However, it does not allow the value to be set, so I added a PromptValue property. Here are the changes to enable this feature:

In CascadingDropDownExtender.cs, add:

///<summary>

/// Optional text displayed by a DropDownList the user has not yet touched

///</summary>

[DefaultValue("")]

[ExtenderControlProperty()]

publicstring PromptValue

{

get {return GetPropertyValue<string>("PromptValue",""); } set { SetPropertyValue<string>("PromptValue",value); }

}

In CascadingDropDownBehavior.js, add:

this._promptValue =null;

and:

get_PromptValue :function() {

/// <value type="String">

/// Value for the prompt text displayed as the first entry in the drop down

/// </value>

returnthis._promptValue;

},

set_PromptValue :function(value) {

if (this._promptValue != value) {

this._promptValue = value; this.raisePropertyChanged('PromptValue');

}

},

and change:

var optionElement =new Option(headerText,"");

to:

var optionElement =new Option(headerText,this._promptValue);

You can the do something like this:

<ajaxToolkit:CascadingDropDownID="CascadingDropDown1"TargetControlID="DropDownList1"

runat="server"Category="Make"LoadingText="[Loading makes...]"

PromptText="-- Please select a make--"PromptValue="SomeUniqueValue"

ServiceMethod="GetDropDownContents"ServicePath="CarsService.asmx">

</ajaxToolkit:CascadingDropDown>

Does anyone else find this useful, or feel it should be added to the extender?

Thanks,

Carl

hi

i want to set the prompt text value if you get this code then please send me

please..............

thanks


Hi, Zarana.

Did you try out the code changes I documented above? Did you have any trouble getting it to work?

Thanks,

Carl


hi Carl,

i am using dll of ajax so this solution is not work. have you any other solution then please reply me.

Please

Thanks

Zarana.


ah...well, I am not on the development team, so I don't have any way to produce the dll distributable version, other than to compile the source myself, and I have other customizations that are unique to my environment. But if you download the source, open the solution in Visual Studio, and apply the changes that I have documented above, you can then create the dll's yourself. I believe you said in another post that you needed it in VB, but I don't use VB so I can't help you there. But, again, making the changes documented above should be straightforward even without knowing C#. If you would like, I could send you the complete .js and .cs files with my changes already made. Then all you would have to do is replace the ones that are there and build the solution.

As you probably know, once you build the dll's, a VB application can talk to a dll created in C# with no problems.

Hope this helps,

Carl


hi Carl,

ya i want that both files.Please send me.

Thanks

Zarana


Okay, what's your email address and I'll send them to you.