#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    28
    Rep Power
    0

    How to convert Forms to MVC???


    Is there a way that I can convert this Tutorial to MVC?

    I managed to separated everything except the Form data.... I didn't know how to go about it.

    Code:
    <asp:Repeater ID="VideosRepeater" runat="server">    <ItemTemplate>       <%# Eval("Title") %> <br />       <object width="427" height="258">            <param name="movie" value="http://www.youtube.com/v/ 		<%# Eval("VideoId") %>"></param>            <param name="allowFullScreen" value="true"></param>            <param name="allowscriptaccess" value="always"></param>            <param name="wmode" value="opaque"></param>            <embed src="http://www.youtube.com/v/<%# Eval("VideoId") %>?"  		type="application/x-shockwave-flash" width="427"  		height="258" allowscriptaccess="always" allowfullscreen="true"  		wmode="opaque"></embed>          </object>    </ItemTemplate>    <SeparatorTemplate>      <br />    </SeparatorTemplate>    </asp:Repeater>
  2. #2
  3. No Profile Picture
    Permanently Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2010
    Location
    Tustin, ca
    Posts
    39
    Rep Power
    0
    You have to use html tables in mvc instead of repeater. You have to modify your code like below:
    1. In your view, use foreach loop to bind data to columns:
    @foreach (var m in Model)
    {
    <tr>
    <td style="border: 1px solid #000000; height: auto; padding: 5px; text-align: center; vertical-align: middle;">
    @m.ColumnName
    </td>
    </tr>
    }
    2. In your view, declare model as IEnumerable:
    @model IEnumerable<ProjectName.Models.ModelName>

    3. In your controller
    a. Declare list as IEnumerable.
    b. Create a private list function to get values from dataset and add to list declared previously.
    c. In Actionresult function, call the private function.
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2013
    Posts
    2
    Rep Power
    0
    I am currently in the process of converting a couple of web form projects over to MVC. At first it was more to get familiar with the MVC, but now I actually really like how the model and the separation it provides.

    The transition over has been a little hard in some area's in that there really isn't a lot of material other than some blogs, stackoverflow, and a couple of video casts. There are two books that are semi-available but, one is already kind of useless in that there have already been a number of changes to the framework that there are better ways in handling some things.

    I also think you will have to really start to learn jQuery if you are already not familiar with it too. So for me - I feel like I am really learning two things as I've been doing this.

    But worth it over all, I would say yes. And I think that converting a small project over is also really a great way to start.

IMN logo majestic logo threadwatch logo seochat tools logo