Generics And Duck-Typing XML In .NET?

Feb 12, 2010

I'm working with some XML representations of data instances. I'm deserializing the objects using .NET serialization but something in my soul is disturbed by having to write classes to represent the XML... Below is what I'd LOVE to do but I don't know if the syntax or if it is even possible:Consider the following:

dim xmlObject = SomeXMLFunction() 'where some function returns an object/string representation of xml...
xmlObject.SomePropertyDefinedInTheXML = SomeFunction()

View 4 Replies


Similar Messages:

Detect Typing From Users - Display UserA Is Typing Message?

Dec 17, 2010

I wrote a chat client 1-1 but I need a way to be able to detect if the user is typing and display "UserA is typing message..." just like MSN messenger or yahoo messenger.. how can I detect that?

View 2 Replies

How To Get Value Of Property By Name Through Generics Of A Class

May 11, 2010

I have a class, let's say class Sample. Sample has unknown properties but inherits an interface ISample. Said interface includes one method which I'm trying to create. This interface has a method called getPropertyValue(object o, string PropertyName).

It returns the value of the o.PropertyName using generics (unless you have a better suggestion). How do I write it? In other words, I want to be able to pass the name (as a string) of a property and return its value. Samples in C# preferrable but VB ok and any comments or suggestions are welcome.

View 2 Replies

Understand Polymorphism When Using Generics In C#?

Aug 25, 2010

I am having a problem understanding how polymorphism works when using generics. As an example, I have defined the following program:

public interface IMyInterface
{
void MyMethod();
}.....

So, at least I haven't completely misunderstood that. I am unsure exactly how I am to write a method that accepts a generic collection of classes that conform to the same interface.

I have a plan to completely hack around this problem if need be, but I would really prefer to do it properly.

View 3 Replies

C# - Reflection And Generics Get Value Of Property?

Apr 29, 2010

i am trying to implement a generic method which allows to output csv file

public static void WriteToCsv<T>(List<T> list) where T : new()
{
const string attachment = "attachment; filename=PersonList.csv";
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.ClearHeaders();
HttpContext.Current.Response.ClearContent();

[Code]....

but I am not able to get the value of the object's property

View 2 Replies

Restrict The Generics To Take Only Value Types?

Jul 12, 2010

I had asked with one question in the interview regarding generics

How can we restricts the one generic method to take only the value types.It should not be able to take reference types.

View 2 Replies

Generics - Declarative Syntax For A Collection Of Value Types?

Jul 16, 2010

I know that in ASP.NET (talking about 2.0 here primarily) one can set a property on an object that takes a collection of things (an enumerable type I'm guessing is the trigger) and then reference it declaritivly. For example:

<ObjectDataSource properties="blahblahblah">
<SelectParameters>
<asp:Parameter />
</SelectParameters>
</ObjectDataSource>

It is the <asp:Parameter /> part which is the root of my question. Say I wanted a simpler collection on a type. Say a List<String> or if generics are out, an IntegerCollection or StringCollection. How would I use that declaratively? Is <string value=''> allowed, or can I put raw values into it like <StringCollection>string, string, string</StringCollection> or what?

EDIT:

I feel like I was not clear enough in my question. I understand that ObjectDataSource implements its SelectParameters property as a ParametersCollection, and that one can use that property declaratively (in an ASPX page) to set up Parameter types within that collection. What I'm wondering is if I made something like StringCollection as a property on another control, is there a syntax (in ASPX) for adding strings to that collection? Or would I have to define a wrapping class like how DropDownList takes ListItems to fill its collection?

View 2 Replies

Mvc Views With CLR Generics Syntax In Inherits Attribute?

Oct 18, 2010

For reasons I won't go into I need to use CLR generics syntax in an ASP.NET MVC view.

I.E. NOT this:

System.Web.Mvc.ViewUserControl<someobject>

but this:

System.Web.Mvc.ViewUserControl`1[[someobject]]

When I run the application I get

Parser Error: could not load type `System.Web.Mvc.ViewUserControl`1[[someobject]]

View 2 Replies

Find # Of Occurrences & Count In String Using Collections / Generics?

Mar 4, 2010

I tried so much working with this to get distinct Words and their count. I'm using ASP.NET 2.0. And i also googled so much.

1)Ex(String): The DOTNET is Very Cool! The Best.

2) Capture all the sequences like Space, FullStop, Question Mark, Exclamation, Apostrophe, New Line....(May be with RegEx?)

3)Split Words According to the above sequences

4)Get Distinct Words(Occurences) and their count based on the input string in 1st statement.

Desired O/P:
The - 2
DOTNET - 1
Is - 1
Very - 1
Cool - 1
Best - 1

This is my Sample Code for your Ref.

[Code]....

View 3 Replies

Security Login - Typing In Url

Apr 5, 2011

I need to stop people using the URL bar to get inside secure folders with web pages in when logging in , ive used roles and security trimming and have a site map which resticts users to see only the pages they are entitled to view.

View 1 Replies

MVC :: Typing A URL Some How Returns /Home?

Mar 5, 2011

I have a weird problem with my MVC application.In my _Layout.cshtml file I have created 3 menu links and each points to a location. On my personal PC clicking each link will browse to the specifc page without any issues. However, when I deployed my app to a hosting website. The first 2 links work fine but the 3rd one returns me to ~/Home

Using IE developer tools here is the network capture:

Request: GET /myapp/mylink HTTP/1.1

Accept: imaged/jped etc..

Refer: /myapp/home

The response is as follow:

Response: HTTP/1.1 302 Found

Location: /myapp/home

I am not really sure why am I getting a HTTP 302 and causing a redirect to /myapp/home.

View 1 Replies

How To Repeat The Same Data In Different Tables Without Typing It

Jul 5, 2010

In access 2003, how do I repeat the same data in different tables without typing it out again. That in another table with different name.

View 5 Replies

Web Forms :: How To Restrict Typing Into A Textbox

Jan 20, 2011

I've got textboxes for dates, and they are hooked up to the jquery datepicker. I would like to disallow actual typing into the text boxes, forcing the datepicker UI to be the *only* method of populating the textbox. I tried setting the textbox to readonly, but that ended up not passing the on-screen-displayed datepicker-selected date back to the server, and hence not saved.

View 4 Replies

How To Add Typing Notification To Chat Application

Apr 13, 2010

I am creating a chatting application, where I want to show typing notifications in private chat.i.e If two users are chatting, when the user is typing message I want to show in chat window of other user that "userName is typing" in the status bar

View 3 Replies

.net - ICustomTypeDescriptor For Simulating Strong-typing?

Jan 31, 2010

I thought about simulating strong-typing for key-value configuration of a new project by providing fake property info via implementing ICustomTypeDescriptor.The configuration instance should provide all default config keys as properties with default values however: I noticed that VS08 intellisense doesn't include "faked" properties which are created in example similar to [URL]

View 1 Replies

AJAX :: Nothing Happens On Typing - AutoCompleteExtender Out Of Work

Oct 14, 2010

I have a AutoCompleteExtender in my form. I tried to use it with some examples in google, but it is not working My environment is: ASP.NET 2.0 C# using Ajax Control Kit 1.0

My page code is:

[Code]....

My asmx page is:

[Code]....

When I type 'a' on the textbox, nothing happens

View 8 Replies

Put Comma On Last 2 Digits While Typing In A Textbox

Aug 12, 2012

I don't have a VS in front of me but i would be needing this one next week when i start working again, so I thought I would be prepared.What i want to do is put a comma "," right before the last 2 digits. So I am thinking of ajax masked edit extender but I don't have VS here so i can't do the testings. If it does not have the exact feature i was thinking of some custom javascript-jquery function . Finally a regex to clear out the wrong formats-characters again if masked extender does not work.

My formatting should be like this: 1234567 to 12345,67 , 1 to 1,00 etc. If doable, I would prefer the mask for the masked extender.

View 8 Replies

MVC :: Strongly Typing View To Custom Type?

Dec 31, 2010

I am integrating asp.net mvc with an existing asp.net web form application. All works well until I try and inherit my view from custom type.

[Code]....

Reference has been added to the assembly containing the above namespace to the web form project. I had manually create an aspx page since the mvc view templates are not available in web forms project. I guess the way view gets bound to the object by telling it where to inherit from or does asp.net mvc performs some hidden plumbing. There weird part was that I could not even bind it to IList<string>.

View 9 Replies

C# - Display Search Results Dynamically As Typing?

Jul 8, 2010

I am trying to build a SharePoint 2007 web part in Visual Studio. This web part should search a sharepoint list and display the results.

What I want to accomplish is to display the results as soon as the user stops typing, so no clicking button involved.

Probably, a combination of text_changed event and onkeydown javascript?

This sharepoint site is "Ajax-enabled", btw.

View 4 Replies

Trying To Add Few White Spaces Between Two Text Boxes By Typing Space Bar?

Jul 18, 2010

In my ASP.NET application, I was trying to add few white spaces between two text boxes by typing space bar. The equivalent HTML source was instead of . So I just wanted to check: is this the new replacement for white space? If yes, why they changed?

View 3 Replies

MVC :: How To Populate Form Fields Without Strongly Typing Model

Sep 28, 2010

I am facing few issues. I am using MVC2.I am developing a form which is being created dynamically based on its layout and all html attributes info stored in DB table. This dynamically generated form stores data(this table have all html field names as columns) in another db table(db is mysql).

I have created ViewModel class in which i get both design table entity objects and data table entity object. I, then, created strongly typed view based on that ViewModel. But the problem is when i rendering html fields using html helpers i.e

TextBox(Model.tblDesign.htmlField_name).it doesnt bind with the columns of Model.tblData whose names are same as of Model.tblDesign.htmlField_name. how can i bind fields of data table?

View 1 Replies

Security :: Viewing Files In A Directory By Typing Path Into Url?

Apr 14, 2010

I have a directory that holds some images for my site. I have noticed that if i put in the my web sites address followed by "/directoryname/imagename.jpg"

it displays the image i have in that directory. Is there anyway to disable this or stop this from happening? so that the images can not be displayed like this

View 4 Replies

Stop IE Users Typing Into The File Upload Input?

Mar 17, 2010

My testers have discovered that if you type free text into a file upload input then none of the buttons on the page work until that text is removed (so the page cannot be submitted).

I am able to replicate this with the following ASPX code (with no code behind):

<%@ Page Language="C#" AutoEventWireup="true" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpload ID="fuTest" runat="server" />
<asp:Button ID="btnSubmit" runat="server" Text="Submit" />
</div>
</form>
</body>
</html>

(Note that I haven't bound any handlers to the page; despite this, the page is submitted when the submit button is clicked only if no text is entered into the upload text box)

Is there any way to prevent users from typing free text into a file upload control? It seems that this is only possible in IE - Firefox and Chrome natively prevent text from being entered into upload input fields.

I've seen solutions elsewhere which suggest hiding input and replacing it with a label / button combo, but this seems like it might cause more problems and work inconsistently across browsers.

View 2 Replies

Visual Studio -to Accept Just Numbers On A TextBox When Typing?

Jun 21, 2010

I have a TextBox & I want to accept just numbers in this TextBox when typing?

View 3 Replies

SQL Reporting :: Pass The Parameter Through The URL Instead Of The User Typing It Into The Text box?

Nov 15, 2010

I've been using asp.net for a number of years now but I am new to reporting services. I have created a report which uses 1 ID parameter. I want to pass the parameter through the URL instead of the user typing it into the text box. I have set the paramented value to hidden and tried to pass it in the url like below:

Report.aspx?ItemPath=%2fReport_test%2fReportValues>rs:Command=Render&ID=fred

However it doesnt recognise the ID paramenter in the url as I get an error message saying that @ContactID is missing.

View 6 Replies







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