Return Multiple Types In Method's Signature?
Oct 13, 2010
I have two methods that do the similar thing. There are small differences here and there, which I can control by passing arguments to them when I call them, so I can effectively merge them. However one returns a string, and the other one an ArrayList. On the top of my head, I could merge them and return an Object, and then get the information I need. Is there a way though to return multiple types in the method's signature? What's the proper way to implement this?
View 5 Replies
Similar Messages:
May 27, 2010
If I'm returning an object, then it's pretty straight-forward. However, if I'm just trying to return whether or not the method was successful or not, what's the best option? Sure ... bool seems obvious - but what if you need to debug or get some additional details out of the method than just "yes/no"? Well that's where a string becomes more obvious, right? You can leave it empty to say that the method was successful or chock it full of details in the case of an error. But this can make it less intuitive to others who may have to run your functions and it also jumbles up everything you wanted to pass back into one large string.
View 3 Replies
May 5, 2010
I have .aspx page methods with return type of string, which work great. I am using some jQuery ajax, and some .NET Ajax "PageMethods.methodName" syntax from the client side to successfully call these page methods. I need to return xml from a page method.... I would LOVE to be able to return system.Xml.Linq.XElement type from page method. I get a serialization circular reference error when I attempt to return XElement or XDocument. I don't really want to return XML.ToString() to client, and then convert string to xml in javascript. What return page method return type(s) would allow me to retrieve xml with jQuery ajax call? I know json is the alternative, but will not give me what I need this time.
View 3 Replies
Jul 31, 2010
Reporting system has list of available reports on a web page. When user clicks on a report new browser window opens, server starts to prepare report (winword document) and then sends it back after 2-10 seconds.
Code in the handler looks like the following:
context.Response.AddHeader("Content-Disposition",
"attachment;filename=report.doc");
context.Response.BinaryWrite(reportDocument);
Is it possible to prepare html content immediately send it back and then continue with time-consuming report preparation not closing connection?
View 3 Replies
Mar 30, 2010
I am trying to create a method that accepts multiple types of controls - in this case Labels and Panels. The conversion does not work because IConvertible doesn't convert these Types.
public void LocationsLink<C>(C control)
{
if (control != null)
{
WebControl ctl = (WebControl)Convert.ChangeType(control, typeof(WebControl));
Literal txt = new Literal();
HyperLink lnk = new HyperLink();
txt.Text = "If you prefer a map to the nearest facility please ";
lnk.Text = "click here";
lnk.NavigateUrl = "/content/Locations.aspx";
ctl.Controls.Add(txt);
ctl.Controls.Add(lnk);
}
}
View 1 Replies
Apr 9, 2010
I have a web control with a text box configured like this:
[Code]....
I am unable to get it to hit the method in my service with a signature like:
public
string[] GetOrganizationNames(string searchText,
int count)
but it does get to the method if I change the signature to:
public
string[] GetOrganizationNames()
For obvious reasons the second one will not do me any good. I have verified the data coming back from the method is good.
View 2 Replies
Apr 23, 2010
i have a dynamic data layer, i.e every user can add custom fields to database tables, so i need dynamic methods in my application.
i know i can use params to specify a variable number of parameters for a method, but the gridview in asp.net looks for a method with the same fields it is updating, i.e if gridview updates fields :name, age, phone, email(suppose email is a custom field of a certain user i.e it doesn't exit for another), and the object data source calls the update method with signature : (name, age, phone, params object[] custom_attributes) an error is generated that the gridview can not find the method with the signature(name, age, phone, email)
View 2 Replies
Jan 3, 2011
I need to validate a digital signature which consists of thumb impression,signature and tokenid which is in pendrive with a columns of a table in sqlserver2008 database. I am using capicom.dll in asp.net 3.5 using c#.
I tried but I am unable to do it.
View 1 Replies
Mar 2, 2011
I have say class/ojbect one which I am returning as details. But then there is a second class that is related to the first that I want to list (and have an option to look at the details). How do I get return both of those?
Example is like in an item as the main piece but there may be details or other items that are related to the main item. I will select them with a linq query but then how do I return them to the same view?
Do I need to have some sort of partial or other form to display the second object type? I don't see where returning the view I can return both.
My thought for right now is to create a new class that contains both of the object types but I know there has to be a better way.
View 3 Replies
Jun 24, 2010
i have 10 employee objects.I want to return these 10 object from a web method to web service client.
View 6 Replies
Jan 28, 2010
I am going to start to work with electronic signatures for a website for my company. Whats best practices and/or implementations. Note, I am not asking for anyone to spoon feed me code. I would like to be able to use a usb signature pad and submit the signature to the website with it.
View 1 Replies
Jan 25, 2010
I have the following statement, I want to turn it into a Public Shared Function :
If isEmployee Then
Dim employeeInstance As New Employee
employeeInstance = GetEmployeeInstanceByUserId(userId)
Return employeeInstance
Else
Dim studentInstance As New Student
studentInstance = GetStudentInstanceByUserId(userId)
Return studentInstance
End If
Public Shared Function GetWorkerInstance(Byval isEmployee as Boolean) As ...(not sure what to write here)...
There two possible return Type. I'm not sure what I should declare for the function return type.
View 2 Replies
Sep 28, 2010
how can i return 401 error from a method return ActionResult?
View 1 Replies
Aug 13, 2010
I am trying to figure out why javascript functions I create with declared return types are not giving me intellisense hints. See code below, specifically updateNextItemTime in Sample.TodoList.
[Code]....
View 9 Replies
Aug 31, 2010
I need help writing a class that will contain three values per item. I'll be passing parameters to a report: Parameter Name, Data type (int, string, date, etc), and Value. When I pass those values to the report using the class they should be in original form (i.e. an integer should be a numeric, a string should be a string, etc.).
I can do it converting the data's value to strings on one end, and reconverting to the original data type on the other, which seems like a lot of runaround. Is there a simple way? Also, if I'm able to store & retrieve the data in it's native format I don't need the "Data type" stored.
View 2 Replies
Sep 8, 2010
What do you think about an ability of having multiple logins and login types to be attached to the same user? Let me explain this by showing how database schema can be re-factored to support this model:
Remove [Password], [PasswordSalt] columns from [Users] database tableAdd [Logins] table with one-to-many relationship between [Users] and [Logins] tables.This will allow one user to have multiple credentials attached to his or her account of different types such as Username&Password, Windows Live ID, Open ID from different providers
You will be able to restrict allowed login types and OpenID providers in web.config
So.. do you think it is a good idea to add support of this model into ASP.NET 4.5/5.0 membership service?
http://aspnet.codeplex.com/workitem/7149
View 1 Replies
Feb 8, 2011
I'm designing a page which makes an ajax call (via jQuery.ajax) to a page method on the server side.On the server side, I have two classes: Agent and Channel.
In the page method, I'd like to return a List<Agent> and a List<Channel> to the client side. How can I return two lists to client side? should wrap them up in one class like:
[code]....
View 4 Replies
Oct 12, 2010
I have an application that allows admins to add types such as document types and training types that are in seperate tables with a foreign key in a transaction table.
When structuring my class I decided to go with an abstract-like pattern (without the factory methods though). So I have a Type abstract class that defines my Save, Delete, and GetList methods. I have a training type class that inherits this class. The thing is all types have 3 main properties - defined in the abstract base - but have different source tables and thus different store procedures in my DbCommand object. So basically I repeat setting up the same parameters on all the derived classes. I would like to implement the common stuff in the base but I am getting thrown off by the difference in data sources.
View 2 Replies
Nov 16, 2010
i use JSon to return allot of results when building a website, but find myself writing a a lot of code like this:
[Code]....
and then simply call this function with whatever IEnumerable results i have my question is would i be on the right lines here, what would be the best possible way to do this as it makes no sense to be writing in MVC and OOP but to keep rewriting code to just FROM ?
View 5 Replies
Nov 24, 2010
I have a class file called ShoppingCartClass.cs. Inside ShoppingCartClass I have a method called CanadaPostShipping.
CanadaPostShipping get passed a lot of variables and then builds an xml, sends it to CanadaPost url and gets back an xml file with the shipping rates.
I would like to pass the xml back to my webpage so in my web page I can check that it has status ok and then extract the information I need.
My testing calling routine looks like this:
[Code]....
The start of my CanadaPostShipping routine looks like this
[Code]....
This is my current ending spot in CanadaPostShipping....where I am getting back the correct xml from CanadaPost
[Code]....
As you can see I am saving it to my thumbdrive.....
What changes would I have to make to my calling routine and the method in the class to return xml "mydoc"?
View 1 Replies
Mar 9, 2011
I'm really new to ASP.Net and for a school project we have to create a login form. Now I have managed to create a login with LINQ doing the following:
[Code]....
And in my html page:
protected void Test_Click(object sender, EventArgs e)
{
if (Class1.Controle(Convert.ToInt32(txt1.Text), txt2.Text))
[Code]....
I was thinking something amongst those lines, but I can't call p.GebruikerWachtwoord. So I'm guessing this is completely wrong.I hope somebody can help me figure this out, and I apologise for the poor explanation, English isn't my native language.
View 3 Replies
Apr 4, 2011
I am fairly new to MVC and just trying to achieve something which I think shouldn't be too complicated to achieve. Just want to know what the best approach for that is. I have an Event-RSVP application (NerdDinner kind) where you go to view details of the event and then click on an AJAX link that will RSVP you for the event.
<%
if (Model.HasRSVP(Context.User.Identity.Name))
{
%>
<p>
You are registered for this event!
<%:
Ajax.ActionLink("Click here if you can't make it!", "CancelRegistration", "RSVP", new { id = Model.RSVPs.FirstOrDefault(r => r.AttendeeName.ToLower() == User.Identity.Name.ToLower()).RSVPID }, new AjaxOptions { UpdateTargetId = "QuickRegister"})
%>
</p>
<%
}
else
{
%>
<p>................
View 2 Replies
Jul 19, 2010
I am coding a classic .asmx web service. The method get data (as a string) from a server, then assign data to an object, then return that object. But I want to cache that object to a XML file for other request. It's because the data from server is not frequently change. Thus, after some minutes, I have to refresh the XML file. When I refresh XML file, I could write object to XML first, then return that object, but that approach maybe slowly.
How can I return the object for client first, then write this to XML file?
View 5 Replies
Jul 9, 2010
VWD 2008 Express. Visual Basic.
I am using the Directory.GetFiles method as follows:
[Code]....
As expected, it returns files with the ".pdf" extension. I would like to be able to specify more than one extension (like "*.doc*" and "*.txt*", etc.). How can I use GetFiles to return files with more than one desired extension, without returning all files?
View 2 Replies
Jan 16, 2011
I am wondering if jsonResult method can be used to return Data Table? If so, is it a json array or a json string?
View 6 Replies