.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Custom mapping from formValues to ViewModel

Posted By:      Posted Date: August 30, 2010    Points: 0   Category :ASP.Net
Let's say i have simple ViewModel : class SimpleViewModel { public string prop1 {get;set;} public string prop2 {get;set;} } And I have following markup:<input type="text" id="prop1input" /><input type="text" id="prop2input" />I am wondering is it possible to make custom mapping from form values submitted via POST to model values, something like this:class SimpleViewModel { [HttpMappingAttr("prop1input")] public string prop1 {get;set;} [HttpMappingAttr("prop2input")] public string prop2 {get;set;} }

View Complete Post

More Related Resource Links

MVC2 UpdateModel method, with custom ViewModel and cruicially.... PartialViews.

Hi, not usually one to ask for help but 2 days on this and not really getting anywhere. I have a view that gets posted back to my controller and I can call updatemodel pass in the FormCollection and everything in the view gets updated and works great etc... The problem is, this view contains several PartialViews that I just can't seem to get the UpdateModel helper to update. All this stuff is strongly typed, I mean my overall viewmodel has properties that expose the data to my partialviews. (just for clarity see below code, "Model" has a property called "AreaListViewModel", which has a property called Areas. "AreaList" is the partialview/usercontrol). <% Html.RenderPartial("AreaList", Model.AreaListViewModel.Areas); %> I'm convinced it is either something to do with the way I add the data to my partialview, like HtmlTextBoxFor syntax. OR the UpdateModel syntax. As mentioned I get my form data back as a "FormCollection". [AcceptVerbs(HttpVerbs.Post)]public ActionResult Details(int Id, FormCollection formData) Many thanks for any help/pointers.        

Mapping custom UDT's (User Defined Types)


We have custom user defined types on SQL 2008. I would like to map these data types for SSIS when exporting / importing data. I've managed to do this successfully for the built-in types such geometry / geography by editing the MSSQLToSSIS10.XML.

My question would be if this is also possible for a custom UDT's created with a different schema, ie [myschema].[MyUDT]? If I define the mapping, SSIS only looks for the UDT definition without the schema (which works in the mapping file without the schema), but fails on the table creation, since the data type cannot be found.

If I define [myschema].[MyUDT] in the MSSQLToSSIS10.xml file, the mapping cannot be found in SSIS. I'm stuck here with a catch 22.

Any advice / workarounds ?


Mapping custom values and columns to destination table **Newb question**



I am copying data from one source to destination SQL CE table using the data flow task. I have two extra requirements which I am not sure how to achieve.

1.)  One source column needs to be mapped to two destination columns. In the column mapping dropdown the column name disappears after mapping it to one destination column.

2) some custom values for columns need to be added, which are not present in source. For e.g. a default value for some destination columns which is not present.

Any pointers would be extremely appreciated. Thanks,

Ganesh Ranganathan
[Please mark the post as answer if it answers your question]

Custom attributes in AD does not show in Property Mapping for Synchronization


Hi, I have problem with the Profile Synchronization in SharePoint 2010.

I have made a connection to our Active Directory and the Synchronization of profiles is working like a charm but when I try to map User Properties to attributes in our AD I can't see the custom attributes we made in the AD. The attributes are added to the AD after the initial connection and synchronization was made. 

Any ideas what I'm doing wrong?




SSIS Custom Destination Component colum mapping issue


Hi ,

I am facing the below issue.

I am developed a custom destination component.I have custom UI also to set some properties.

Once i save the component and do the mapping in the Show Advance Editor Colum Mapping.This is working fine.

The problem starts Next.If I edit the component and do some changes  and say Ok ,In the output colum mapping all the mappings which i have already been set is getting removed.Then again i have to remap it.Ho to keep the existing mapping if we edit the component?

need help to solve this issue.

Programmatically Mapping Custom SharePoint Column on Non-browser Enabled InfoPath Form


I have an InfoPath form, which, due to control requirements, is not browser enabled. It is being programmatically added as a content type to SharePoint (MOSS 2007). All users have Office 2007 installed so they will be able to open the form. I also have a custom multi-line column in the SharePoint document library. I can manually publish the form and map the column to a field of the form, but I need to be able to do this programmatically.

We are currently deploying the forms by modifying the publish url in the xsf during install. We have tried to modify the site coulmn GUID in the template xsf during install without success.

Does anyone have any ideas as to how we can programmatically promote the InfoPath field so it is visible in SharePoint?

SharePoint custom column not appearing in the add mapping popup


Have different Custom Columns created at various level:

  • Site Column
  • Doc. Lib
  • Content type

Added the above in document library.

The doc. lib is also populated with relevant data.

  1. created a content source for the Web App
  2. Did full crawl
  3. went to create managed property

But custom columns not appearing in the add mapping popup except the one used in Content Type?






Dialogs and ViewModel - Using Tasks as a Pattern

The ViewModel/MVVM pattern continues to gain popularity, with a blog post showing up every so often, and with tweets and retweets popping up even more often :-). At the same time, there are some interesting topics beyond the core pattern that continue to fuel experimentation. A big one amongst those is how should applications use dialogs when using the view model pattern.

The crux of the problem is the desire to keep the view model independent of UI concerns, and ensure it can be tested in a standalone manner, but that often comes to odds when you want the view model to launch a dialog, and/or do some work after the dialog is closed.

Custom Controls in C# .NET

Embedding user controls in a Windows form is just like adding a simple button or text box that are already provided with .NET. These basic controls were written essentially like you code your own controls. Typically the controls you design are to be used in multiple forms or to modularize your code. These reasons help reduce the amount of code you have to type as well as make it easier for you to change your implementation. There should almost never be any reason to duplicate code because it leaves a lot of room for bugs. So, implementing functionality specific to your control in the control's source code is a good idea. This reduces code duplication as well as modularize your code, which is a good programming guideline.

A Generic Dialog ViewModel

I worked on a wpf viewmodel for dialogs, because it seemed strange to me that you needed for instance windows forms dialogs to open or save files in wpf. So I set about creating my own wpf dialogs. After creating the dialog viewmodels there still remained a small issue with the library and also I didn't have much time to write an article about it. I however published the library containing the viewmodels for dialogs with another article on my blog

Writing custom MembershipProvider

ASP.NET Membership mechanism allows to use the build-in server tables to store and retrieve user data. By default, this mechanism can only be used with SQL Server database to which Microsoft provides suitable MembershipProvider class.
Inheriting from this abstract class, developer can use his own table(-es) from any database and use any database engine other than SQL Server, like Oracle, DB2 etc.

Custom Editing Behavior for DataGridView TextBox Columns

For various reasons I'm using a DataGridView instead of a ListView, and while configuring the DataGridView to look like a ListView wasn't much of a problem, there's one thing that got on my nerves, which is the behavior of textbox cells in edit mode: It is much too easy to leave the edit mode accidentally, simply by pressing the cursor keys at the wrong time. For example when the text caret is positioned behind the last character of the textbox cell content, and you press the right arrow key

Write Custom WebParts for SharePoint 2007

The popularity of SharePoint Portal Server 2003 led Microsoft to tightly integrate the next SharePoint version, Microsoft Office SharePoint Server (MOSS) 2007, with its ASP.NET 2.0 WebPart framework. This tight integration enables the ASP.NET and SharePoint developer to do a number of things that previously weren't possible

Writing Custom Web Parts for SharePoint 2007

As I mentioned in an earlier blog post, SharePoint 2007 is built on top of ASP.NET 2.0, which means you can now use ASP.NET 2.0 features (Forms Authentication, Master Pages, Membership, Site Navigation, New Data Controls, etc) when building SharePoint sites. This is true for both the new Windows SharePoint Services 3.0 version (which will be a free download) as well as Microsoft Office SharePoint Server 2007 (which costs money).

Custom views on .aspx webpage


Hi again, i have a client that needs me to create a custom view on thier webpage similar to Microsoft Word.

It goes about that, when I click on an image it redirects me to another page and must create a custom view for a certain paragraph on that page. I am not sure how to do this and wonder if anyone knows how.

I am using C# programming language if that helps at all. I Heard that using javascript would work but i dont know javascript yet so is there any alternative?

Set Custom Paper size in C#.net 3.5


Dear All,

I have to set custom paper size 6X8 inches

plz tell sugest me code how to do it.

in C#.net 3.5

i m using Asp.net 3.5 Crystal report

i have to do it programiticlly



How to implement custom HttpContext for each request under class that implements IHTTPHandler


Hello All,

I created an application and implemented IHTTPHandler for all incoming request ending with ".aspx" extension.

Under "ProcessRequest" module, I am creating an instance of HttpContext (with URL attributes different from my application's URL i.e. if I am working on localhost then speciying Yahoo.com as its URL) and assigning it to "context" which comes as method argument.

After redirection, an error is generated. Also, the custom HTTPContext is not passed to the requested page (default.aspx, in my case.)

Code is as follows.

    Public Sub ProcessRequest(ByVal context As System.Web.HttpContext) Implements System.Web.IHttpHandler.ProcessRequest
            Dim requestedUrl As String
            Dim targetUrl As String
            Dim urlLength As Integer
            'Save settings which will be used while redirecting to appropriate page
            requestedUrl = context.Request.RawUrl
            If requestedUrl.IndexOf("?") >= 0 Then
                targetUrl = requestedUrl.Substring(0, requestedUrl.IndexOf("?"))
                targetUrl = requestedUrl
            End If
            If targetUrl = Nothing Or targetUrl.Length = 0 Then
                targetUrl = requestedUrl
            End If
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend