Generic Function To Return String Or Xdocument?
Nov 11, 2010
I want to write a generic function which return either string or Xdocument
[Code]....
In default.aspx
XDocument doc = api.CreateJob<XDocument>("xyz");
threws the exception "Invalid cast from 'System.String' to 'System.Xml.Linq.XDocument'."
How can i do this
View 6 Replies
Similar Messages:
Dec 10, 2010
ASP.NET 3.5 C# I am joining two tables using Linq. Table names are MapAssets and ExitPoint. In Database they are related with 'has a relationship'
I am writing a function in my BLL to return the joined table
public List<ExitPoints> GetExitPointDetailsByProjectID(int iProjectID)
{
ctx = new CoreDBDataContext();
var exitPointDetails = from ma in ctx.MapAssets
join ep in ctx.ExitPoints
on ma.MapAssetID equals ep.MapAssetID
where ma.ProjectID == iProjectID
select new
{
//would like to have data from both tables here
ctx.MapAssets,
ctx.ExitPoints
};
return exitPointDetails.ToList();
}
This obviuosly doesn't work. And I dont know what to return at all. All constraint I have for the return is to be able to be bound to a gridview. is this the correct way? Or else whats the correct way?
View 6 Replies
Mar 7, 2010
i try to return string value from the function i wrote for getting string value from the table for that i havecommon stored procedure
public string getdata(string str)
{
string datanew;
[code]...
View 2 Replies
Jan 26, 2011
At debug time I would like to see what are the keys in my InitParams collection - I can't seem to be able to list them.
EDIT:As Jon suggests below, this might be a bug within the Silverlight debugger. To reproduce, just create a new Silverlight Application within Visual Studio 2010 and just edit code
{
public partial class MainPage : UserControl
{ [code]...
View 2 Replies
Jun 16, 2010
I have a method like:
public T Get<T>(string key)
{
}
Now say I want to return "hello" if the type is a string, and 110011 if it is type int.
how can I do that?
typeof(T) doesn't seem to work.
I ideally want to do a switch statement, and return something based on the Type of the generic (string/int/long/etc).
View 5 Replies
Oct 30, 2010
how would i go about returning a generic list in json format, can anyone point me to any good examples.
View 2 Replies
Jun 8, 2010
Given the function
[code]....
When 'return false' is fired, I'm assuming that the function is stopped at that point and there's no need for exit fors and things like that?
View 1 Replies
Jun 2, 2010
Question: I want to call a generic function, defined as:
Public Shared Function DeserializeFromXML(Of T)(Optional ByRef strFileNameAndPath As String = Nothing) As T
Now when I call it, I wanted to do it with any of the variants below:
Dim x As New XMLserialization.cConfiguration
x = XMLserialization.XMLserializeLDAPconfig.DeserializeFromXML(Of x)()
x = XMLserialization.XMLserializeLDAPconfig.DeserializeFromXML(GetType(x))()
x = XMLserialization.XMLserializeLDAPconfig.DeserializeFromXML(Of GetType(x))()
But it doesn't work. I find it very annoying and unreadable having to type
x = XMLserialization.XMLserializeLDAPconfig.DeserializeFromXML(Of XMLserialization.cConfiguration)()
Is there a way to call a generic function by getting the type from the instance ?
View 5 Replies
Feb 9, 2010
I have a generic list which contains a class called Parameter. Parameter contains 2 integers, ParamType and ParamValue. A generic list is built containing a small number of values List<Parameter> myList I have created a function which passes in 2 parameters. These are passed individually but are used to create a new Parameter within the function. The Parameter is tested against myList, and if it is found removed. In order to do this I have used the remove function, the syntax being:
myList.Remove(new Parameter(ParamType, ParamValue));
The remove isn't working and at present I'm using LINQ to do it.
View 2 Replies
Mar 16, 2010
I am currently binding a Nullable bit column to a listview control. When you declare a list view item I need to handle the case when the null value is used instead of just true or false.
<asp:Checkbox ID="Chk1" runat="server"
Checked='<%# HandleNullableBool(Eval("IsUsed")) %>' />
Then in the page I add a HandleNullableBool() function inside the ASPX page.
protected static bool HandleNullableBool(object value)
{
return (value == null) ? false : (bool)value;
}
This works fine but I need to use this in several pages so I tried creating a utility class with a static HandleNullableBool. But using it in the asp page does not work. Is there a way to do this in another class instead of the ASPX page?
<asp:Checkbox ID="Chk1" runat="server"
Checked='<%# Util.HandleNullableBool(Eval("IsUsed")) %>' />
View 1 Replies
Feb 1, 2011
I have written the following functions(1 & 2) in a class file(say abc.vb) to execute a sql statement in code behind.
[Code]....
View 35 Replies
May 7, 2015
I am using multiple gridview in my asp page.How to bind mutiple gridview Like code below this.
protected void Page_Load(object sender, EventArgs e) {
if (!Page.IsPostBack) {
Label1.Text = Session["projectname"].ToString();
GridBind();
} else {
//Response.Write("Postbac occurs");
[code].....
View 1 Replies
Jan 5, 2010
i followed this link [URL] and i get selected value from dropdownlist using jquery
i created 3 partial views .
i need depend's on dropdownvalue redirect to partial page , so how can i implement in jquery with conditions?? or how can i implement in this function Public Function FetchData(ByVal dropdownValue As String) As ActionResult??
View 1 Replies
Apr 1, 2010
I'm trying to use a Generic list for my class but I'm getting this error "Conversion from type 'EnumerableQuery(Of VB$AnonymousType_105(Of String))' to type 'String' is not valid."
[Code]....
-imperialx
View 3 Replies
May 26, 2010
So here's my XML file:
[code]....
View 2 Replies
Jan 6, 2011
I have a function in .CS file. i want to return many values fetched in the function to .aspx.cs file(both files in the same project)
How to return a values from the below function(.CS file code is as follows):
using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
[Code]....
I want to pass advocates,jjj,tyear,year,petitioner1,resp1,sb etc... How can i do it??
View 3 Replies
Apr 15, 2010
I have an XDocument that looks similar to
<root>
<a>
<b foo="1" bar="2" />
<b foo="3" bar="4" />
<b foo="5" bar="6" />
<b foo="7" bar="8" />
<b foo="9" bar="10" />
</a>
</root>
I wish to change the attribute foo to something else, and the attribute bar to something else. How can I easily do this? My current version (below) stack overflows with large documents, and has an awful smell to it.
string dd=LoadedXDocument.ToString();
foreach (var s in AttributeReplacements)
dd = dd.Replace(s.Old+"=", s.New+"=");
View 2 Replies
May 6, 2010
I have an XML file named PageData.xml in my App_Data folder. I want to populate an XDocument with this file using XDocument.Load.
If I supply the full physical path it works, i.e.:
XDocument vXDoc = XDocument.Load("/Work/Project/Web/100413 Dev/App_Data/PageData.xml");
...where "Work" is a folder on my C: drive.
If I try a relative path like this, though, I get a DirectoryNotFoundException:
XDocument vXDoc = XDocument.Load("AppData/PageData.xml");
"Could not find a part of the path 'C:Program Files (x86)Common FilesMicrosoft SharedDevServer10.0AppDataPageData.xml'."
This is obviously wrong, but there must be an easy way to set the correct relative path?
View 1 Replies
Mar 28, 2011
internal static void GetUserData(int userId, out string userName,
out string userEmail, out string userPassword)
{
using (SqlConnection con = Util.GetConnection())
{
con.Open();
using (SqlCommand cmd = new SqlCommand("usp_UD_SelectById", con))
{
cmd.CommandType = CommandType.StoredProcedure;
cmd.Parameters.Add("@UD_ID", SqlDbType.Int).Value = userId;
cmd.Parameters.Add("@UD_UserName", SqlDbType.NVarChar, 100).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@UD_Password", SqlDbType.NVarChar, 100).Direction = ParameterDirection.Output;
cmd.Parameters.Add("@UD_Email", SqlDbType.NVarChar, 100).Direction = ParameterDirection.Output;
cmd.ExecuteNonQuery();
userName = Convert.ToString(cmd.Parameters["@UD_UserName"].Value);
userEmail = Convert.ToString(cmd.Parameters["@UD_Email"].Value);
userPassword = Convert.ToString(cmd.Parameters["@UD_Password"].Value);
}
}
}
and the call
string userEmail;
string userName;
string userPassword;
MemberHelper.GetUserData(userId, out userName, out userEmail, out userPassword);
Sometimes I need to get just one parameter from the out parameters, how can I call the function when I want to get just one:
string userPassword;
MemberHelper.GetUserData(userId,"","",out userPassword);
View 1 Replies
Feb 8, 2011
[Code]....
This method always returns '-1' (Fail) while it is expected the method return '0' (Success).
View 2 Replies
Mar 12, 2011
I have written an insert stored procedure which is called by my business logic layer, I want to return the new ID to the function once it has executed but i'm not sure how.
My SP uses RETURN SCOPE and when I have tested this it works but how I get that into a variable in the BLL function I don't know.
View 15 Replies
May 8, 2010
How to get return value of java script function from aspx.vb..
View 1 Replies
Feb 24, 2011
Without giving away specifics: basically, I have a bunch of users adding content to my site. What happens now is ajax sends the text to a web service which does its thing, sends the info to the DB, Sends the user an e-mail, and then returns a response to the browser to do something.
What I would like to do is change that order. I want to return a response to the browser so the user is not waiting on the e-mail to send before they get their response. Basically, I'm trying to gain every milisecond I can to quicken the response, and there's no reason for the user to wait for the server to send their e-mail before it tells them that everything worked ok. If the info went to the DB, that's all the user needs to know, they'll know the e-mail sent when it shows up in their inbox. I notice this is an issue on my local machine which has no SMTP server and can actually hang the page response up for a few extra seconds because it's throwing errors trying to send something with no SMTP server.
So, I know in my function when I say
[Code]....
it WORKS, but I want to send the e-mail after the return. Is there ANY way to get this to happen?
View 5 Replies
Jan 20, 2010
I call the javascript function in cs using button.attributes.add("onclick","function();");
how can i return a val to cs's string variable from js?
View 2 Replies
Feb 21, 2011
I am looking for a c# function to return a portion of the html. Say I have pages that render html of about 60 k in length, I want to email to users showing only the first 2k and add a link to the original page.
Sure there is a Substring function with String, but it will give me a lot of unclosed html tags.
View 4 Replies