Passing A Web Service An Unknown Number Of Parameters?

Apr 28, 2010

I'm relatively new to utilizing web services. I'm trying to create one that will be accepting data from a ASP.Net form whose input controls are created dynamically at runtime and I don't how many control values will be getting passed. I'm thinking I'll be using jQuery's serialize() on the form to get the data, but what do I have the web service accept for a parameter? I thought maybe I could use serializeArray(), but still I don't know what type of variable to accept for the JavaScript array.

Finally, I was thinking that I might need to create a simple data transfer object with the data before sending it along to the web service. I just didn't wanna go through with the DTO route if there was a much simpler way or an established best practice that I should follow. Thanks in advance for any direction you can provide and let me know I wasn't clear enough,

View 3 Replies


Similar Messages:

Passing Multiple Parameters To Web Service

Oct 6, 2010

I have a simple Web Service method defined as:

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string MyWebMethod(string foo, string bar)
{
// DataContractJsonSerializer to deserialize foo and bar to
// their respective FooClass and BarClass objects.
return "{"Message":"Everything is a-ok!"}";
}
I'll call it from the client via:
var myParams = { "foo":{"name":"Bob Smith", "age":50},"bar":{"color":"blue","size":"large","quantity":2} };
$.ajax({
type: 'POST',
url: 'https://mydomain.com/WebServices/TestSvc.asmx/MyWebMethod',
data: JSON.stringify(myParams),
contentType: 'application/json; charset=utf-8',
dataType: 'json',
success: function (response, status) {
alert('Yay!');
},
error: function (xhr, err) {
alert('Boo-urns!');
}
});
However, this yields the following error (a breakpoint on the first line in MyWebMethod() is never hit):
{"Message":"No parameterless
constructor defined for type of
u0027System.Stringu0027.","StackTrace":"
at
System.Web.Script.Serialization.ObjectConverter.ConvertDictionaryToObject(IDictionary2
dictionary, Type type,
JavaScriptSerializer serializer,
Boolean throwOnError, Object&
convertedObject)
at
System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeInternal(Object
o, Type type, JavaScriptSerializer
serializer, Boolean throwOnError,
Object& convertedObject)
at
System.Web.Script.Serialization.ObjectConverter.ConvertObjectToTypeMain(Object
o, Type type, JavaScriptSerializer
serializer, Boolean throwOnError,
Object& convertedObject)
at
System.Web.Script.Services.WebServiceMethodData.StrongTypeParameters(IDictionary2
rawParams)
at
System.Web.Script.Services.RestHandler.InvokeMethod(HttpContext
context, WebServiceMethodData
methodData, IDictionary`2
rawParams)
at
System.Web.Script.Services.RestHandler.ExecuteWebServiceCall(HttpContext
context, WebServiceMethodData
methodData)","ExceptionType":"System.MissingMethodException"}

I'd like to pass in two string parameters and use DataContractJsonSerializer to write new Foo and Bar objects. Am I missing something?

View 3 Replies

C# - Passing Parameters In Windows Service?

Aug 18, 2010

I want to develop a windows service which will be accepting a datatable from an aspx page. Both the windows service and the website are hosted on same machine.

Also I need to set a date and time on which this service is to work. this date and time are to change according to customer needs. once again the date and time are to be fed from the aspx page.

View 6 Replies

JQuery AJAX Not Hitting Web Service When Passing Parameters?

Jul 28, 2010

js:

[code]....

I put a break point inside MyWebMethod. When I invoke this call on the page, the break point never gets hit. It works fine when I remove all parameters from MyWebMethod's signature and pass in '{}' from JS as parameters. Once I try to pass in a string parameter, it stops working.

View 1 Replies

DataSource Controls :: Grab Unknown Parameters From Stored Procedure From Code Behind?

May 3, 2010

I am trying to allow users to grab their stored procs and call certain ones from within code. I can get the stored procedures and then fill a dropdown with them, but what I cannot find at this point is how to get the parameters that each stored procedure needs. I would like, once an SP is chosen from the dropdown to make a call to the db with that sp name and grab its paramter list so I can report what needs to be sent in to the user.

View 1 Replies

Create An RDLC Report When Total Number Of Columns Are Unknown?

Nov 21, 2010

One of the reports I am creating has dynamic number of columns - a datatable gets returned from the stored procedure, the number of columns depend on the number of items defined in the database (one column for each item, other than some fixed columns). Is it possible for me to use RDLC report to generate a report in this case? All the calculations are already done int he report, I am looking at RDLC only for the sake of export to excel/pdf and repeating header/footer.

View 2 Replies

Forms Data Controls :: Creating A Form With An Unknown Number Of Rows?

Sep 13, 2010

I'm pretty new at ASP .NET but not to ASP. I've got a form I need to create where I don't know how many entries will be added. It has the following format:

"Age" "Duration" "Period of Duration" "etc..."

Last30Days

1-5 Months ago

6-11 Months ago

Age

Age

Age

etc.

So the Age column always has the first 3 options and then an unknown number of Age values that can be inserted. I've created a table that has the first four fields (Last30days, 1-5months, 6-11months, age) and I was thinking I could just order by those 4 columns for display. The problem I have is I'm not sure on how to proceed. Does anyone have any good ideas on how to handle this situation? Ideally data entry people could use the same form for both entering and displaying the data.

View 6 Replies

C# - What Is Passing Parameters To SQL

Jul 9, 2010

In this answer to my question of how to insert data into SQL Server he mentioned passing parameters instead of string concatenation like I currently have.

Is this really necessary for security? If so, what exactly is passing parameters? When i google it I get a lot about stored procedures. Is that what I want, I do not know about stored procedures....yet.

EDIT:

Ok, here is what I got. It seems to update the database correctly and eventually I will change the hard coded ints to inputs from a label. confirm if how I did this is not vulnerable to any sql injection or hacks.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;
using System.Data;
using System.Data.Sql;
using System.Data.SqlClient;
public partial class Stats : System.Web.UI.Page
{
public SqlDataReader DataReader;
public SqlCommand Command;
string queryString = ("INSERT INTO UserData (UserProfileID, ConfidenceLevel, LoveLevel, HappinessLevel) VALUES (@UID, @CL, @LL, @HL);");
//string queryString = ("INSERT INTO UserData (UserProfileID, ConfidenceLevel, LoveLevel, HappinessLevel) VALUES ('a051fc1b-4f51-485b-a07d-0f378528974e', 2, 2, 2);");
protected void Page_Load(object sender, EventArgs e)
{
LabelUserID.Text = Membership.GetUser().ProviderUserKey.ToString();
}
protected void Button1_Click(object sender, EventArgs e)
{
//connect to database
MySqlConnection database = new MySqlConnection();
database.CreateConn();
//create command object
Command = new SqlCommand(queryString, database.Connection);
//add parameters. used to prevent sql injection
Command.Parameters.Add("@UID", SqlDbType.UniqueIdentifier);
Command.Parameters["@UID"].Value = Membership.GetUser().ProviderUserKey;
Command.Parameters.Add("@CL", SqlDbType.Int);
Command.Parameters["@CL"].Value = 9;
Command.Parameters.Add("@LL", SqlDbType.Int);
Command.Parameters["@LL"].Value = 9;
Command.Parameters.Add("@HL", SqlDbType.Int);
Command.Parameters["@HL"].Value = 9;
Command.ExecuteNonQuery();
}
}

View 7 Replies

Passing Parameters To Usercontrol?

Apr 21, 2010

when i worked in .NET 1.1 i used to pass parameters to user control using the method- (if the name of the usercontrol is "tables")

dim r As tables =
CType(Page.LoadControl("~/usercontrol/tables.ascx"), tables)

and calling public property of the usercontrols.

the problem is that i can't the way to do it in 2008 ver of .NET, it is not recognize the usercontrol.... how can i pass parameters to the usercontrol in run time?

View 10 Replies

MVC :: Passing Parameters To ListView

Oct 9, 2010

[Code]....
and my Index
[Code]....

View 1 Replies

C# - Passing Parameters With Conditionally?

Aug 3, 2010

i have a dropdownlist with seven different optins like (date, subject, press, cia, media...) and user will select one of the item from the dropdownlist and click on search button to get the results.here is my repository class GetInquires method which accepts 7 parameters but it will pass only one prameters at a time to the storeproc and in case of Date (it will pass both from/to)

public List<Inquiry> GetInquiries(string fromDate, string toDate,
string subject, string press,
string cia, string media,

[code]...

View 6 Replies

SQL Reporting :: Passing Parameters Through Sub Reports?

Aug 24, 2010

I am trying to use a parameter field where there is a subreport in my main report but i keep getting the error "subreport cannot be shown" when running the report.

p.s - I have just set the parameters the same in the subreport as the main report.

View 2 Replies

Web Forms :: Passing Parameters To New Window

May 23, 2010

I have a page with a lot of pictures on it. I want the user to be able to click on the picture and either bring up a popup type of window passing it the Param name and value , or to have the picture be replaced with this object.

<object id="ADR2" type="application/x-Autodesk-DWF"
width="250" height="250"> <param name="dwffilename"
value="path" /> </object>

I have found a number of places describing how to bring up a popup window, but not on how to pass it the values.

View 2 Replies

Web Forms :: Passing Parameters To ExpressionBuilder

Nov 8, 2010

I have a custom ExpressionBuilder in whixh I'm trying to add a list of optional parameters. My method would be declared as follows:
public static string GetResource(string expression, params object[] parameters) { }

The way I'm calling this method from an ASP.NET page is this at the moment:
<ext:Button ID="btnEdit" runat="server" Text="<%$ AppResources : edit_text %>">
Does anyone know how to perform this method call, but using optional parameters?

View 6 Replies

ADO.NET :: Passing Values To TableAdapter Parameters?

Nov 12, 2010

I am creating a DataSet to attach to a report (*.rdlc). In the DataSet is a TableAdapter that has the GetData(@start, @end) function. Can someone please explain how I get values in to @start and @end? I have searched and seen that it might have something to do with overriding the Fill function in the DataSet code behind file. Please let me know.

View 1 Replies

AJAX :: Passing The Parameters In Sql Datasource?

Mar 13, 2011

I have used a sql data source to connect to ORACLE.

Select command is working fine, as soon as I try to provide a parameter, it doesn;t work.

Getting following error " ORA-01036: illegal variable name/number"

Tried searching for error message -- but It says the parameters name has to be less then 32 characters, which is what I have.

<asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:DevConnection %>"
ProviderName="<%$ ConnectionStrings:DevConnection.ProviderName %>" SelectCommand="Select ID, Name from Employee where state = @stateid">
<SelectParameters>
<asp:ControlParameter Name ="stateid" ControlID = "drdState" PropertyName = "SelectedValue" />
</SelectParameters>

View 2 Replies

Dynamic DropdownList Passing Parameters

Mar 6, 2013

I have a dynamic created drop down list - and I set the event of it to be like this:

ddlAnswer.ID = "ddlistAnswer" + QuestionID;
ddlAnswer.SelectedIndexChanged += new EventHandler(ddlAnswer_SelectedIndexChanged);

Please note that drop down list is dynamic, and in selectedIndexChanged, I would like to pass the "QuestionID" to that selectedindexchanged to work on my logic. Is there a way to pass it to that method as command argument or something?

Code:
protected void ddlAnswer_SelectedIndexChanged(object sender, EventArgs e)
{
//wanting that question id here
}

View 1 Replies

Web Forms :: Passing Parameters To SP With Condition?

Jun 9, 2012

STR= "SELCT * from tbl1 ";
if (drpyrsal.SelectedValue != "--Select--")
{
STR= STR+ " and Year([frmdt])=" + drpyrsal.SelectedValue + " ";
}
if (drpmonth.SelectedValue != "--Select--")
{
STR= STR+ "and Month([frmdt])=" + drpmonth.SelectedValue + " ";
}

and execute it with dataset

how can i do the same with SP

SqlCommand cmd = new SqlCommand("usp_SP1", con); // Stored procedure
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.AddWithValue("@yr", drpyrsal.SelectedValue);
cmd.Parameters.AddWithValue("@mon", drpmonth.SelectedValue); 

View 1 Replies

Web Forms :: Passing Parameters From A Datalist To Another Page?

Jun 11, 2010

passing parameters from a datalist to another page.

this is how my app works:

i have a database ( access) a table with the following columns: id,title,desc,photo.

another table with the following columns: (startsin, endsin,price,tId)

on the first page (tourpack.aspx) i have a datalist, when user clicks on a button that is in the templateitem of the datalist, he will be transfered to another page called (showtour.aspx). what im trying to do is passing the ID parameter from the first page (table 1) to the second page (showtour.aspx) with the id number so he can see the specific details of that "tour" that are located In the second table.

View 8 Replies

Web Forms :: Passing Multiple Parameters To VB.net Function

Jan 7, 2010

Im wonding what the correct syntax is to pass 2 parameters from a Ascx control into a Vb.net function? Heres what I currently have:

<asp:Literal
ID="CommentFooterLiteral1"
Visible='<%# Eval("Approved") Or IsModerator() %>'
Text='<%# FormatFooter(Eval("Anonymous"), Eval("DisplayName"), Eval("CreatedDate")) &#43; "
" &#43; GetModeratorStatus(Eval("UserId")) %>'
runat="server"
/>

The Function "FormatFooter", needs to pass in Anonymous and DisplayName parameters. Anyone know the correct syntax for doing this?

View 2 Replies

Web Forms :: Passing Multiple Parameters In The Hyperlink?

Sep 20, 2010

I am trying to pass parameters in the hyperlink.

The code in sending page is as below

[Code]....

View 2 Replies

DataSource Controls :: Passing Parameters To ObjectDataSource

Aug 9, 2010

I followd Brian Orrell LINQ tutorial for paging/sorting and created a gridview bound to an ObjectDataSource through a method call which gets data from adatabase. My form includes two buttons with a textbox next to each one of them. I need to be able to populatte th egridview depending on the button that was pressed, I cannot figure out how signal my method which button was pressed.
[Code]....
[URL]

View 1 Replies

C# - Passing Parameters When Submitting A Form Via JQuery In MVC?

Oct 23, 2010

I'm trying to do a form submit to my controller through jQuery Ajax. The following code works for the most part, however, the ThreadId parameter does not get passed. If I call the controller directly without using jQuery, it gets passed, but when using jquery, I don't see the ThreadId after form.serialize(). WHat would be the easiest way to pass parameters (like ThreadId) to jQuery form post?

[code]....

View 1 Replies

Web Forms :: Passing Multiple Parameters To An Exe From Web Application

Jan 24, 2011

I need to execute the following exe file with multiple arguments from asp.net web application

"C:Program FilesSysteminvoke.exe" /project "UPLOAD" /app "Default App" /task "XMLGEN" /parm.OutputDirectory "c: emp"

I tried the following asp.net code,

[code]....

View 4 Replies

Web Forms :: Passing Parameters In Dropdownlist And Sqldatasource

Jun 3, 2010

I am trying to pass the parameters dynamically thru Sqldatasource and get the results in grid view. Based on the dropdown list selection it has to show the results in grid view. When I hard code its giving correct results but when passing thru parameters i'm unable to get the results in grid view.

Output shud be something like this:

Select the value: 123

124

125.

Lets say user selects '123', the query it runs in sqldatasource is Select col1,col2,col3 from table1 where col1 LIKE '123%'

results will be 12301,12302,12303 with other columns in grid view.

[code]....

View 6 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved