.net - Calling A Generic Function In VB.NET / C#?

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


Similar Messages:

Generic List - Remove Function Not Working

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

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

Return Generic.List<Anonymoustype> From A Function In C#?

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

Create A Generic Util Function To Be Used In Eval Page?

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

ADO.NET :: Creating A Generic Function - Data Access Layer

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

Data Controls :: Common Generic Function To Bind Multiple GridView?

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

Web Forms :: Getting Error Calling Javascript Function From Another Javascript Function

Jan 3, 2011

Getting error calling Javsscript function from another Javascript function

[Code]....

View 4 Replies

Calling Javascript Function From VB.Net?

Nov 15, 2010

Is is possible to call a Javascript function whether it's embedded in the HTML markup file or a .js file from a VB.Net procedure/function?

View 3 Replies

Calling A Function Every Five Minutes?

Oct 17, 2010

i want to display Hello World Message. How to call this function every five minutes?

View 1 Replies

Calling A Javascript Function In C#?

Mar 26, 2011

i wanted to show or hide duplicate records according to query. So, I need to know how to call the javscript function from C# codebehind.

<a onclick="Grid1.insertRecord(); return false;" id="a2" href="javascript:">Save</a>

When I click save i need to show a popup which i Have written in javascript.

if (!exist)//exists is the query
{
System.Web.UI.Control my = FindControl("a2");
a2.Attributes.Add("onclick", "retrun HideDuplicate()");

This line returns an error saying "a2 doesnot exist in current context."

View 3 Replies

Calling Function From VB.Net Class?

Mar 11, 2011

Just wondering how I do this, Im creating a class that will have my common database functions. So for example I've created a function db_con in a class called db_functions.How do i use that db_con function in for example my homepage vb code?Do I import the class? I've tried typing the full class and method name, no joy so far?

View 1 Replies

Calling A C# Function From Page?

Jul 1, 2010

I wrote a small function in C# that manipulates pdf files using itextsharp. Is it possible to call this function from a classic asp page?

View 6 Replies

Calling JQuery Function From Code Behind C#?

Mar 7, 2010

I have the following jquery function

[code]...

but I need a way of calling the growlUI jquery function from my code behind file in C# rather than clicking on a div in the UI.

Is this possible?

View 1 Replies

Web Forms :: Calling Function In Codebehind

May 11, 2010

I have a master that I am trying to load a certain stylesheet based on some data. I have a function in the code behind of the master page:

[Code]....

Then in the head of the master, I have:

[Code]....

I've tried "Eval" too but if I set a breakpoint in the LoadFacilityStyles function, it never even gets triggered/called. Is this possible to do with .master?

View 4 Replies

MVC :: Calling PartialView From A Javascript Function?

Aug 2, 2010

how to call a partial view from within a Javascript function? I've looked around the web, but all the examples that I have been able to find are examples using Ajax.ActionLink or Ajax.BeginForm.

When a user clicks on an item, I want to be able to hide/display some Divs and possible do other operations before calling the partial view. ActionLink doesn't appear to provide that ability. Depending upon the item the user clicked, I may be assigning the results of the PartialView to the same Div, or to a different Div.

What I'm looking to achieve, is to have an onclick handler associated with the item which performs whatever other operations might need to be done, then assign the result of the call of the PartialView to the appropiate Div. In some instances, the function might even be making two separate calls to PartialViews, to update the content of two separate Divs.

View 1 Replies

C# - Calling A Button OnClick From A Function?

Feb 27, 2011

I have a button with OnClick=Button_Click. I want to call Button_Click from another function but the problem is that I need to give it:

object sender, EventArgs e)

What should I enter for those parameters? Is there any way around it?

View 2 Replies

Calling/writing The Results Of A Function?

Dec 13, 2010

I am trying to show the results of a function with information from a form on the previous page.I was working on this project in the past and the following code worked, but it does not anymore.I know its alot to look at but if someone could help that would be great.The form on the first asp page:

<FORM METHOD="POST" ACTION="RollingRiverFarmCustomerQuote.asp" id="InformationForm">

View 10 Replies

C# - Calling A Function After A Response.Redirect?

Aug 18, 2010

I have an ASP.NET site and I'm using jGrowl to display notifications to the user. This works great when the user stays on the same page, but what if I'm redirecting the user.

Example, AddPerson.aspx is a page for adding a new person. After a person is added the user is redirect to People.aspx. I'd like to then display the notification 'Josh Smith has been added.'.

I currently have a function in my Master page executing the javascript:

public void DisplayNotification(string html, string header)
{
string text = """ + html + """;
string options = "{ header: '" + header + "', life: 6000 }";
string scriptJGrowl = "$.jGrowl(" + text + ", " + options + ");";
ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), scriptJGrowl, true);
}

How can I call this after a Response.Redirect?

View 4 Replies

Calling Classic Asp Function That Creates Hash Value

Mar 7, 2010

I've a pre-supplied public function in classic asp that creates a hash value - it is pretty complex and I'd rather not convert it to .net if at all possible (mainly as I don't understand half of what it does!) I'm running it under IIS7 on VWD2008 express. How would you call a function in that asp file? do you have to redirect or as it is #included into the asp.net file, is there an eaiser way? At the moment the complier does not spot the function and says it is not declared.

View 2 Replies

Calling Javascript Function Inside Page?

Mar 11, 2011

using vb.net/asp.net 2005

I have a content page (<asp:content>) where I am using javascript and normally I am adding the attribut in the code-behind page. however I now need to add a javascript function that will cause when the body or panel loads. I have a test javascript function that simply shows an alert box but I cannot get it to display. Is there a special way to do this in a content page?

[Code]....

View 3 Replies

C# - Button Is Not Calling Server Side Function?

Apr 27, 2010

I'm instantiating an asp:Button inside a data-bound asp:GridView through template fields. Some of the buttons are supposed to call a server-side function, but for some weird reason, it doesn't. All the buttons do when you click them is fire a postback to the current page, doing nothing, effectively just reloading the page.

Below is a fragment of the code:

[Code]....

The viewBtn above should call the viewBtnClick() function on server-side. I do have that function defined, along with a proper signature (object,EventArgs). One thing that may be of note is that this code is actually inside an ASCX, which is loaded in another ASCX, finally loaded into an ASPX.

View 2 Replies

C# - Calling JQuery Function From Code Behind After Postback?

Feb 22, 2011

I m trying to call a JQuery .click funtion after page postback from code behind. I m using ASP.NET with C#.

View 2 Replies

Calling .NET Web Service Function Via GET Method With JQuery

Apr 26, 2010

I'm trying to call web service function via GET method using jQuery, but having a problem. This is a web service code:

[WebService(Namespace = "http://something.com/samples")]
[ScriptService]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [Code]....

And I get an error because of this (error handler is called).

View 7 Replies

Web Forms :: Calling A Function Before Page Redirection?

May 3, 2010

I 've some session variables which are used on a page, i want to clear those session variables as soon as user is redirected from this page,

Is there any method which i can call before user is redirected from this page ?

View 10 Replies







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