extract data from webservice ?WSDL - c#

my teacher gave me a url to a webservice of my school with the purpose of extracting some data to help me with a project im making. the thing is he doesnt want to tell me how i am supposed to extract the data from it. i know it has a lot of operations/methods or whatever it's called and i know it has something to do with xml. im doing a website in asp.net and c#.
i've been searching for some code but i dont really understand it.
NameoftheService.Service myservice = new NameofTheService.Service();
and to call the method/operation (example):
var abc = myservice.GetWeather(parameter);
but i cant get this thing to work. i've replaced the code above with correct information but it says could not execute query. i dont really know what to do

To bind grid in asp.net is as simple as binding it with object list. Consider the product service. So your code should be like...
ProductsService.DataSetWebService ws = new ProductsService.DataSetWebService();
GridView1.DataSource = ws.GetProducts();
GridView1.DataBind();

One of the properties of NameOfTheService.Service will be a DestinationURL or ServiceURL that you need to set.

Related

Simple way to get information from /.auth/me to C# variable

I need to get givenname and user_id from /.auth/me into my web form application. I'm able to load and look at the values by adding /.auth/me to the end of the link to my page, but not sure how to get them into my C# code. I would like to set these to a C# variable so I can display them on my pages, and send them to the database.
I've been looking through the documentation for hours, but not really having any luck with success.
The main thing I'm trying to achieve is
var name = /.auth/me(givenname)
var id = /.auth/me(user_id)
Is there a simple way to accomplish this?

adding razor statement in javascript

Im trying to add some C# code in my javascript. But I can't parse my var name into the C# code.
What I want is this:
$.ready(function(){
var name = $("#input");
#Class.text(name)
});
But it wont allow me to parse the name.
This is a short version of what i got, the #Class represent a more complex function
The syntax is indeed incorrect.
The var name = $("#input"); is javascript. It is executed at the client end after the document is loaded. The #Class is server side and is executed when the page is being generated.
You cannot use javascript variables in C#. What is it that you are trying to achieve; there may be a different way to do so.
--
Update : You are trying to call a c# method from javascript.
Overall this will require a post back to the server - see http://blog.bobcravens.com/2009/11/ajax-calls-to-asp-net-mvc-action-methods-using-jquery/
#MichaelTotKorsgaard Based on our discussion in the comments of your question, I think I now understand. Unfortunately what you're trying to do simply won't work. It doesn't work that way. The reason you do AJAX/JSON is because, once C#/MVC/ASP.NET returns HTML (it doesn't actually know if what it returns is valid), it's up to the Client to "do stuff" with it. That's where Javascript comes in. But the server-side MVC and client-side JS don't actually know anything about each other. You Need to either 1) post back or 2) use AJAX.
It's time to saddle up and learn how to do it :)
If you give more details about what you're actually trying to accomplish -- like what you're trying to load from JS/AJAX -- then I'm sure SO can give you more information to set you on the right path.

Javascript var inside a c# function inside Javascript

I am trying to write a javascript function that calls an Dictionary value and than tries to split it on a ยด_'. The problem is that the Key to get the value from Dictionary is in an Javascript var that is extracted from a dropdownlist. Is it possible to use an Javascript var inside an c# function inside Javascript?
the Code as it is now:
var Category = document.getElementById('Properties').value;
var Name = document.getElementById(Category).value;
Category = '#Model.Dictionary[Name].Split('_')[0]';
EDIT:
People are misinterpreting my problem, the .Split function does work but the Dictionary[Name] is giving me problems. if i enter
var Category = document.getElementById('Properties').value;
var Name = document.getElementById(Category).value;
Category = '#Model.Dictionary["Bicycle"].Split('_')[0]';
into the code it works perfectly, but I want to get the "Bicycle" part dynamically out of an DropDownList.
EDIT 2:
Okay I have decided that what I am over thinking the situation and that what I am trying to do needs alot more work than is needed, found a beter solutions, thanks for everybody that tried to help me.
You're a bit mixed up between client and server side. To interact with server side code like this, you'll need to either post to the server or write an AJAX callback to call a server method.
http://mikehadlow.blogspot.com/2008/10/mvc-framework-and-jquery-ajax-heaven.html
No, that is not possible. All the server code runs before the page is sent to the browser, and all the client code runs after.
What you would have to do to use the dictionary in the client code is to create Javascript code from the server side, that recreates the dictionary on the client side.
If that's not possible, you would have to make an AJAX call to the server.
I have avoided the issue completely by having the DropDownList have different values in Value and Text, doing this is can get the wanted input that used to be in the Dictionary out of the Value of the DropDownList without changing the Text.

CRM 2011 - Display all entities in option set

I just started working with Dynamics CRM 2011 and need to do some tasks but I simply don't know how. Really hope you can help me with this.
I need to set the values for a picklist(option set) through code behind, it should display all published entities in the solution everytime the form of my custom entity is loaded.
I've searched the web and all I found was the next piece of code, but I absolutely have no idea what to do with is (yeah, I'm newbie, didn't you notice):
RetrieveAllEntitiesRequest req = new RetrieveAllEntitiesRequest();
req.EntityFilters = EntityFilters.Privileges;
req.RetrieveAsIfPublished = true;
RetrieveAllEntitiesResponse resp = (RetrieveAllEntitiesResponse)service.Execute(req);
I tried to do the same with some JScript samples I found on the SDK but I still couldn't manage to insert the values into the picklist. Please give a hint or something. Thanks.
In that case, I think, you should create an entity and put a lookup on form instead.
I've never seen using a picklist for dynamic data, I use them only for static.
They're like global enums.
But, they say about addOption at MSDN Xrm.Page.ui Control methods web page.
Have you tried this one?

jquery datatables fnfilter + script performace

I am away from my development workstation so I thought I'd ask this in hopes of getting an answer when I try it tomorrow. I have a two part question relating to a web application i built using c# jquery and jquery datatables:
1) I know that we can set the value of fnfilter as metioned on their page using something like:
var oTable;
$(document).ready(function() {
oTable = $('#example').dataTable();
/* Filter immediately */
oTable.fnFilter( 'test string' );
} );
however is there a way to retrieve the value entered by the use in the search bar? I was thinking along the lines of
var aContainer= oTable.fnFilter()
or
var aContainer= oTable.fnFilter($(this).html())
2) My application has to retrieve values from another source on the web. These are the value displayed in the datatable. Most of my processing(counting, etc..) is done client side and has drastically slowed down generating the web app. Does anyone know of any suggestions to increase performance of client side scripts specifically datatables?
If your datatable is really instantiated as oTable = $('#example').dataTable(); then doing this:
var textEntered = $('#example_filter input:text')[0].value;
Should return whatever the user entered on the field for filtering.
In answer to #1, you can get the value of the text entered into the search box by doing
// Assume the table's id attribute is 'blah'
var search_string = $('#blah_filter>input').val();
As far as #2, have you considered server-side processing of the data and sending the result to the client?
This article
might give you a big help if you decide to write server side code. Now researching it myself (and not looking forward to implementing custom filtering!).

Categories