.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

Templated HTMLHelpers

Posted By:      Posted Date: October 14, 2010    Points: 0   Category :ASP.Net

Hey.. I'm new to the .NET MVC Framework scene...

I've been reading about it and abstracted both M and C from MVC. My question here is just to help me understend how the View works, here it goes:

I've got 2 tables: List and Item, both of them have repositories and controllers, in the Lists View i want it to be possible for me to add and remove Items. The Item will not have a page of its own, everything will be done in the List Create and Edit page. I tried using EditorFor, DisplayFor, they dont seem right. Is it? How could I do that?

Curiosity: if I added another table: PossibleItems, which contains the possible values for the Items (o rly?) and will have its own page for including possible items, how would it go?

This might seem like an exercise from a MVC Tutorial book but itll really help me!


Matheus Simon.

View Complete Post

More Related Resource Links

OnItemCommand not firing in Templated User Control


I have a templated user control with single instance template attribute. It works great for everything except the following scenario:


    <asp:UpdatePanel ID="upDirectoryBrowser" runat="server">
        <asp:AsyncPostBackTrigger ControlID="fsBrowser" EventName="FolderSelected" />
        <asp:AsyncPostBackTrigger ControlID="flsBrowser" EventName="FileSelected" />
        <asp:AsyncPostBackTrigger ControlID="flsBrowser" EventName="LinkSelected" />
        <table width="100%">
                <td style="width: 230px;">                        
                    <ntc:FolderSelector ID="fsBrowser" runat="server" OnFolderSelected="fsBrowser_FolderSelected"
                    OnControlException="fsBrowser_ControlException"  /> 
                    <ntc:FileSelector ID="flsBrowser" runat="server" OnFileSelected="flsBrowser_FileSelected"
                    OnControlException="fsBrowser_ControlException" O

Dynamic Data (Scaffolding Templated Sites) [REPOST]


Just been using this for a few days, but love it already.

I was wondering what some of the plans were for things like role/user-level security, or even 'type' security.

For some real-world 'for-instance' examples:

  • How would I go about deciding/filtering out which tables are visible?
  • What would the guidance be for making a particular field available to edit for a particular user (set of users)?
  • Can I tie into events (or something) at the model level to filter out data?

I easily built a custom control based off some of your examples and it's already up and working in the site.  I can really see where this is going to help in the protyping of admin apps, specifically with internal or early-versions of software, and while I get the idea it is really a springboard for more complex development, what is available here is just awesome.

 Thanks for any info/suggestions to the above questions.



DataTemplate trigger to set templated parent property


Hy everybody,I am struggling with a problem.I basically want to provide a data template for my data model and when a trigger on the view happens,I want to change a property in my data model.I cannot figure out how to tell the Setter that it needs to change a property of the templated parent. Here is how it looks now:

My data model for a "Line" looks like this:


public class LineModel : DependencyObject
    public ushort Value
        return (ushort)base.GetValue(ValueProperty);
        base.SetValue(ValueProperty, value);
    public static DependencyProperty ValueProperty = DependencyProperty.Register("Value", typeof(ushort), typeof(LineModel));


Strongly Typed HtmlHelpers and View Models



I am not sure why this happens, but when I have an Html.TextBoxFor(model => model.SomeObject.SomeProperty), when I post, the property of that object is always null.

When I look at the markup generated, I see <input type="text" name="SomeObject_SomeProperty" id="SomeObject.SomeProperty" value = "" />

If I change the helper to Html.TextBoxFor(model => model.SomeObject.SomeProperty, new {id = "SomeProperty"}) the controller is then able to pick the value up. Why is this happening? I feel as though I shouldn't have to be specifiying the id for the textbox as it works when fine when not using child objects on a view model, IE <%: HtmlTextBoxFor(model => model.SomeProperty) %>.

Bind() inside Templated User Control inside InsertItemTemplate does not bubble values up to the Obje


I have a ObjectDataSource and a ListView referencing it.

I have created a Templated User Control (see: http://msdn.microsoft.com/en-us/library/36574bf6.aspx) and placed it in the ListView's InsertItemTemplate

It has one template <ContentTemplate>. Inside that template, I've defined a couple of server controls with their properties = '<%# Bind("colName") #>'.

See below:

            <uc:InsertItemRow ID="ucInsertItemRow" runat="server">
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