Tag Archives: CSS

[RESOLVED]Always filtering Index View on Bool Entity / Displaying only a subset of data

I would like to have the index view (code below) always filter the data on a bool entitiy so that only a subset of the database displays – not the entire database.

If anyone could point me in the right direction, I would appreciate it.

Index.cshtml

@model PagedList.IPagedList<GenericWebApplication.Models.Class_EntitySet01>
@using PagedList.Mvc;
<link href="~/Content/PagedList.css" rel="stylesheet" type="text/css" />

@{
    ViewBag.Title = "Class_EntitySet01";
}

<h2>Class_EntitySet01</h2>

<p>
    @Html.ActionLink("Create New", "Create")
</p>

@using (Html.BeginForm("Index", "Class_EntitySet01", FormMethod.Get))
{
    <p>
        Find by name: @Html.TextBox("SearchString", ViewBag.CurrentFilter as string)
        <input type="submit" value="Search" />
    </p>
}

<table>
    <tr>
        <th>
            @Html.ActionLink("Last Name", "Index", new { sortOrder = ViewBag.NameSortParm, currentFilter = ViewBag.CurrentFilter })
        </th>
        <th>
            First Name
        </th>
        <th>
            @Html.ActionLink("Enrollment Date", "Index", new { sortOrder = ViewBag.DateSortParm, currentFilter = ViewBag.CurrentFilter })
        </th>
        <th></th>
    </tr>

        <th></th>
    </tr>

@foreach (var item in Model) {
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.Property_Entity01)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Property_Entity02)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.Property_Entity21)
        </td>

        <td>
            @Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
            @Html.ActionLink("Details", "Details", new { id=item.ID }) |
            @Html.ActionLink("Delete", "Delete", new { id=item.ID })
        </td>
    </tr>
}

</table>

<br />
Page @(Model.PageCount < Model.PageNumber ? 0 : Model.PageNumber) of @Model.PageCount

@Html.PagedListPager(Model, page => Url.Action("Index",
    new { page, sortOrder = ViewBag.CurrentSort, currentFilter = ViewBag.CurrentFilter }))

Class_EntitySet01Controller.cs

using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Mvc;
using GenericWebApplication.Models;
using GenericWebApplication.DAL;
using PagedList;
using System.Data.Entity.Infrastructure;

namespace GenericWebApplication.Controllers
{
    public class Class_EntitySet01Controller : Controller
    {
        private GenericWebApplicationContext db = new GenericWebApplicationContext();

        // GET: /Class_EntitySet01/
        public ActionResult Index(string sortOrder, string currentFilter, string searchString, int? page)
        {
            ViewBag.CurrentSort = sortOrder;
            ViewBag.NameSortParm = String.IsNullOrEmpty(sortOrder) ? "name_desc" : "";
            ViewBag.DateSortParm = sortOrder == "Date" ? "date_desc" : "Date";

            if (searchString != null)
            {
                page = 1;
            }
            else
            {
                searchString = currentFilter;
            }

            ViewBag.CurrentFilter = searchString;           
            
            
            var class_entityset01s = from s in db.Class_EntitySet01s
                           select s;

            if (!String.IsNullOrEmpty(searchString))
            {
                class_entityset01s = class_entityset01s.Where(s => s.Property_Entity01.ToUpper().Contains(searchString.ToUpper())
                                       || s.Property_Entity02.ToUpper().Contains(searchString.ToUpper()));
            }
            
            switch (sortOrder)
            {
                case "name_desc":
                    class_entityset01s = class_entityset01s.OrderByDescending(s => s.Property_Entity01);
                    break;
                case "Date":
                    class_entityset01s = class_entityset01s.OrderBy(s => s.Property_Entity21);
                    break;
                case "date_desc":
                    class_entityset01s = class_entityset01s.OrderByDescending(s => s.Property_Entity21);
                    break;
                default:
                    class_entityset01s = class_entityset01s.OrderBy(s => s.Property_Entity01);
                    break;
            }

            int pageSize = 3;
            int pageNumber = (page ?? 1);

            return View(class_entityset01s.ToPagedList(pageNumber, pageSize));
        }

        // GET: /Class_EntitySet01/Details/5
        public ActionResult Details(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Class_EntitySet01 class_entityset01 = db.Class_EntitySet01s.Find(id);
            if (class_entityset01 == null)
            {
                return HttpNotFound();
            }
            return View(class_entityset01);
        }

        // GET: /Class_EntitySet01/Create
        public ActionResult Create()
        {
            return View();
        }

        // POST: /Class_EntitySet01/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include = "Property_Entity01,Property_Entity02,Property_Entity21")] Class_EntitySet01 class_entityset01)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Class_EntitySet01s.Add(class_entityset01);
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
            }
            catch (RetryLimitExceededException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }
            return View(class_entityset01);
        }

        // GET: /Class_EntitySet01/Edit/5
        public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            Class_EntitySet01 class_entityset01 = db.Class_EntitySet01s.Find(id);
            if (class_entityset01 == null)
            {
                return HttpNotFound();
            }
            return View(class_entityset01);
        }

        // POST: /Class_EntitySet01/Edit/5
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit([Bind(Include = "ID,Property_Entity01,Property_Entity02,Property_Entity21")] Class_EntitySet01 class_entityset01)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.Entry(class_entityset01).State = EntityState.Modified;
                    db.SaveChanges();
                    return RedirectToAction("Index");
                }
            }
            catch (RetryLimitExceededException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                ModelState.AddModelError("", "Unable to save changes. Try again, and if the problem persists see your system administrator.");
            }
            return View(class_entityset01);
        }

        // GET: /Class_EntitySet01/Delete/5
        public ActionResult Delete(int? id, bool? saveChangesError = false)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            if (saveChangesError.GetValueOrDefault())
            {
                ViewBag.ErrorMessage = "Delete failed. Try again, and if the problem persists see your system administrator.";
            }
            Class_EntitySet01 class_entityset01 = db.Class_EntitySet01s.Find(id);
            if (class_entityset01 == null)
            {
                return HttpNotFound();
            }
            return View(class_entityset01);
        }

        // POST: /Class_EntitySet01/Delete/5
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Delete(int id)
        {
            try
            {
                Class_EntitySet01 class_entityset01 = db.Class_EntitySet01s.Find(id);
                db.Class_EntitySet01s.Remove(class_entityset01);
                db.SaveChanges();
            }
            catch (RetryLimitExceededException /* dex */)
            {
                //Log the error (uncomment dex variable name and add a line here to write a log.
                return RedirectToAction("Delete", new { id = id, saveChangesError = true });
            }
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            db.Dispose();
            base.Dispose(disposing);
        }
    }
}

__________________________________________________________________

Programming Environment:

    Visual Studio 2013
    .NET 4.5
    Entity Framework 6 (EntityFramework 6.1.0 NuGet package)
    OS: Windows 7

Project Based On:
Getting Started with Entity Framework 6 Code First using MVC 5

http://www.asp.net/mvc/tutorials/getting-started-with-ef-using-mvc/creating-an-entity-framework-data-model-for-an-asp-net-mvc-application

var class_entityset01s = from s in db.Class_EntitySet01s
                           where s.SomeField == true
                           select s;

Thank you SO much!

[RESOLVED]datepicker work once in partialview mvc5

Hi,I’m having this annoying problemwith datepicker.
I’m working with MVC5, Bootstrap, jquery 1.10.2 and jquery-ui-1.11.1.
I have 2 datepickers in a partial view that is call it from a bs modal, and when I show the modal a second time, the datepicker stop working, and I’ve tried almost everything, take a look:

**JS Code**

<script type="text/javascript">
(function () {
$("#EDate").datepicker();
$("#RDate").datepicker({ minDate: "-1d" });

$("#divm").on("hidden.bs.modal", function () {
$(".datepicker").datepicker("destroy");
$(".datepicker").removeClass("hasDatepicker").removeAttr('id');
})
})();
</script>

**Razor Code**

@Html.EditorFor(model => model.EntryDateOperation, new { htmlAttributes = new { id = "EDate", @class = "form-control datepicker" } })
@Html.EditorFor(model => model.EntryDateOperation, new { htmlAttributes = new { id = "RDate", @class = "form-control datepicker" } })

**The bootstrap modal**

<div id="divm" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="Embarcaciones" aria-hidden="true">
<div class="modal-dialog" style="text-align:right">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
<div style="text-align:left">
<h4 class="modal-title" id="mTitulo">Nueva Embarcaci&oacute;n</h4>
</div>
</div>
<div id="mEdit" class="modal-body" style="width:100%; text-align:center">
@{Html.RenderPartial("_myclass", Model.Myclass);}
</div>
</div>
</div>
</div>

**and I added z-index on jquery ui css**

.ui-datepicker {
width: 17em;
padding: .2em .2em 0;
display: none;
z-index: 9999999 !important;
}

As you can see I have tried almost everything, but I don’t know what else can I do, Thanks for any kind of help :)

lebarros

$(".datepicker").datepicker("destroy");

I believe this could be the problem. You are removing the date picker with the destroy method

[RESOLVED]Can Asp.net mvc on visual Studio 2012 , creates mobile views (with .mobile.cshtml extension) that are based on jQuery mobile

Currently i want to create a new asp.net mvc4 web project inside Visual Studio 2012. but i have the following question about the current capabilities for creating mobile views.

For example if i right click on an action method , i will get a dialog to create a new view, and it will automatically create a View (with .cshtml) for me using some bootstrap classes to have a responsive design, but my question is if there is way to create
mobile specific views using the same approach . or if i want to create a mobile specific view that uses jquery mobile i need to do this from scratch, i mean asp.net mvc and visual studio only supports creating view that have .cshtml and not based on jQuery
mobile?

Yah, just follow bootstrap’s mantra "mobile first"

http://getbootstrap.com/css/

i did not mean if asp.net mvc supports rendering mobile views , what i meant is if Razor can automatically generate views based on jQuery mobile. For example in asp.net mvc 5 & Visual studio 2013 will generate the views based on Bootstrap template for desktop
browser. but is there a way to generate views based on jQuery mobile (i mean automatic generation, by right click on the action method and create a new view, so the generate view will have .mobile.cshtml and will use the jquery mobile syntax ?)

I don’t think there is a mobile view scaffolding generator. You should manually create it. You can create a template and use it for all your mobile views.

I think although MVC4 uses Razor finally it’s rendering into a html file in the browser.So you can define your all css responsive classes with divs inside a layout file.You can find default layout files inside the Shared folder under the Views folder.By
right click you can create a new layout file as i said above with your Bootstrap or whatever responsive files.And finally when creating views you can define that created layout for the views.

[RESOLVED]Using col-sm & col-xs without specifying the senario for the large screen

I have the following code inside a web template that i am using :-

</div>
<div class="row panel">
<div class="col-sm-3 hidden-xs">
@Html.Action("Menu", "Nav")
</div>
<div class="col-xs-12 col-sm-8">
@RenderBody()
</div>
</div>

but now i got confused on how the two divs will display in a full screen (large screen), as i understand the markup as follow:-

- the Menu will be hidden on X-small screens and occupy 3 columns on small size,, but what about large screens ?

- the RenderBoy will occupy 12 in x-small screens and 8 in small but what about large screens ?

Can anyone advice ?

Thanks

if you look at the break points in the documentation for Bootstrap it shows that the classes "cascade" up so if you only set the col-sm-8 it is also then col-md-8 and col-lg-8 without specifying it.

http://getbootstrap.com/css/

hope it helps

Hi john,

First, please refer to remojr76’s reply

Secondly, base on http://getbootstrap.com/css/#grid, it says that:

•Grid classes apply to devices with screen widths greater than or equal to the breakpoint sizes, and override grid classes targeted at smaller devices. Therefore, applying any .col-md- class to an element will not only affect its styling on medium devices but also on large devices if a .col-lg- class is not present.

Best Regards

Starain Chen

[RESOLVED]Ajax.BeginForm() and validaiton message?

How to display the validation message of the Model while using Ajax.BeginForm() ?

It does not matter between Html.BeginForm and Ajax.BeginForm. while declaring validation

1) Please add validation message in Model class as in Html.BeginForm validation

2) Then specify modal dialog name as UpdateTargetId in Ajax.BeginForm

Ajax.BeginForm("Action", "Controller", new AjaxOptions { HttpMethod = "POST", UpdateTargetId = "modal-dialog-name"})

If you are loading controls after the Ajax post and want to enable the validations after the post, you need to manually invoke the validator as shown below

$.validator.unobtrusive.parse('form');

Here is the code I used earlier for this

Ajax.BeginForm(new AjaxOptions() { UpdateTargetId = "AjaxViewContainer", OnSuccess = "RegisterAjaxEvents();", LoadingElementId = "LoadingDiv" });

JavaScript

function RegisterAjaxEvents() {
    $.validator.unobtrusive.parse('form');
    //remaining code
}

Hi abhi0410,

Thanks for your post.

First You enabled validation in the web.config page:

<add key="ClientValidationEnabled" value="true" />   
<add key="UnobtrusiveJavaScriptEnabled" value="true" />

And you can follow these steps:

Unobtrusive AJAX Form Validation in ASP.NET MVC

http://www.codeproject.com/Articles/460893/Unobtrusive-AJAX-Form-Validation-in-ASP-NET-MVC

More information:

Ajax.BeginForm and validation

Ajax.BeginForm not working with Html.ValidationSummary

If there’s anything else I can do for you regarding this matter, please feel free to post it in this forum.

Best Regards,

Eileen

Hello
pprasannak,

i tried but your solution little different.

I have partial view with save button but on first click my server validation occurs.

And when i click second time then i get those error message in my view.

My partial view is loaded dynamically in a view based on click of button present in the view.

<script type="text/javascript">
    function RegisterAjaxEvents() {
        $.validator.unobtrusive.parse('form');
    }
</script>

@using (Ajax.BeginForm("Add", "Account", new AjaxOptions() { UpdateTargetId = "messageid", HttpMethod = "Post", OnSuccess = "RegisterAjaxEvents();" , InsertionMode=InsertionMode.Replace}))
{
    @Html.AntiForgeryToken()
    <div>
        @Html.ValidationSummary(true)
        <table>
            <tr>
                <td>
                    @Html.LabelFor(model => model.name, new { @class = "label" })
                </td>
                <td>
                    @Html.TextBoxFor(m => m.name, new { @class = "textbox" })
                    @Html.ValidationMessageFor(model => model.name, string.Empty, new { @class = "error" })
                </td>
            </tr>
            <tr>
                <td>
                      @Html.LabelFor(model => model.Userid, new { @class = "label" })
                </td>
                <td>
                    @Html.TextBoxFor(m => m.Userid, new { @class = "textbox" })
                    @Html.ValidationMessageFor(model => model.Userid, string.Empty, new { @class = "error" })
                </td>
            </tr>
            <tr>
                <td>
                    @Html.LabelFor(model => model.Email, new { @class = "label" })
                </td>
                <td>
                    @Html.TextBoxFor(model => model.Email, new { @class = "textbox" })
                    @Html.ValidationMessageFor(model => model.Email, string.Empty, new { @class = "error" })
                </td>
            </tr>
            <tr>
                <td>
                    
                </td>
                <td>
                    <div id="messageid"></div>
                    <div>
                        <input type="submit" value="Save" class="btn btn-default" />
                    </div>
                </td>
            </tr>
        </table>
    </div>
}

Hi
Eileen ni

Can you please look into my code snippet and guide me why the validation fires on second click and not in first click?

Thanks

abhi0410

OnSuccess = "RegisterAjaxEvents();"

The validation is firing second time because you are explicitly calling the RegisterAjaxEvents function on the success of the first button click.

For some reason your initial loading is not registering the validator. As a work around try this

<script type="text/javascript">
    function RegisterAjaxEvents() {
        $.validator.unobtrusive.parse('form');
    }

  RegisterAjaxEvents() // call the function manually
</script>

Also move this javascript to the end of the page (after end of the BeginForm)

Hi
pprasannak
,

Thanks.

It works by calling explicitly. but what could be the reason that validator is not registered in initial loading?

And how to highlight the textbox for which the error has occurred?

Ok i could add validation color to the textbox by simply passing the below css pattern to my css file

.input-validation-error
{
    border: 1px solid #ff0000;
    background-color: #ffeeee;
}

Rest was taken care by jquery.

Bundle process removing css content property

After i bundle my css all css content property are change to
?

I tested and have the same issue with vs2012 and 2013, with first and lastest version of web.optimization and webgrease, single or double quotes make no diference, still removing the content property value and set as
?

UPDATE

I was thinking maybe, the problem is with encoding or line endings and again… makes no diference, tested with Unix, Windows, UTF8 with and without BOM, Windows 1252, ISO-8859-1.

Bundle register:

bundles.Add(new StyleBundle("~/Content/Css/Styles").Include( "~/Content/Css/iconFont.css", "~/Content/Css/metro-bootstrap.css", "~/Content/Css/metro-bootstrap-responsive.css", "~/Content/Css/select2.css", "~/Content/Css/Site.css"));

Before bundle:

.icon-newspaper:before {
    content: 'e001';
}

.icon-pencil:before {
    content: "e002";
}

After bundle:

.icon-newspaper:before{
    content:"?"

}

.icon-pencil:before{
    content:"?"
}

Interesting…. just yesterday I was having bundling issues with both CSS and JS files.  What I found out and I don’t know why was if I removed all MIN files my issues went away!  

Thanks for reply. 

All min files are already removed.

Have you tried using the minification with WebEssentials first to see if that helps?

Thanks for trying to help as you said i try with web essentials and same issue… i even uninstall web essentials for sure.

[RESOLVED]Data annotation validation

Hi
I have two questions regarding the data annotation validation.

1. Can you change the look og how the error message i show. Maybe use some of my own html
2. Can i use data annotation validation with viewmodels? I know that i can put data annotation on the attributes of my viewmodels but is it the way to go?

Hope someone can help
Jakobjensen

Yes, in Viewmodels you can implement the INotifyableObject interface.  MVC will call this implementation just before the post back enters the controller to validate anything you want. There are two modes to validation 1) For the Models itself using data
annotations and 2) And any custom business rules you need to implement in the View model.  To notify the view, the ViewModel validate method will return a collection of <ViewResult>  if you use the "Yield return new ViewResults("blah, blah blah")" construct
you can write as many validation rules as you need an very easily send them to the view.  

Reminder, make sure you set up something like @Html.ValidationSummry(true or false) up in the view in order to see them.  One final note, any Action method checking for Model.ViewState is valid any bypassing logic, will force those errors to be fixed!  In
other words it is a controller decision on what to do, however, why set up exception parsing rules for this if you just need to warn the user of something rather than forcing a correction.  For warning messages you are better off implementing on client side.
 Just create a hidden field or dialog that pops up from using JQuery or Javascript for those.

Can you change the look?  Anything is possible if you implement the entire system yourself or use JavaQuery to manipulate the DOM after document.ready.  You’ll easily be able to spot what MVC does to generate those messages.  Jquery can do anything with
them. 

Thanks for the answer.

So the way i do now is that i have some homemade javascript to handle client side validation.
And then i want to use entity frameworks serverside validation.
How do i make entity framework talk with my javascript.
I want the same error to show up both for client side errors and for server side errors

Im not sure i made myself clear…
I want to validate with the annotation from my business classes.
I have viewmodels.
And i have some javascript that validates and thats fine by me. But i dont know how to handle to kind of validation..

Lets say the user enters something wrong. Then he see my error message from javascript.

But if he has javascript disabled he should see the message from entity framework.

How do you handle these to validation?

Hi Jakobjensen,

jakobjensen

Can you change the look og how the error message i show. Maybe use some of my own html

I suggest that you could specify the style in the parent element, such as:

<div style="..."> 
@Html.ValidationMessageFor(m => m.UserName)
</div>

You also could custom HtmlHelper to custom it.

# Custom ValidationSummary template Asp.net MVC

http://stackoverflow.com/questions/5857851/custom-validationsummary-template-asp-net-mvc-3

jakobjensen

Can i use data annotation validation with viewmodels? I know that i can put data annotation on the attributes of my viewmodels but is it the way to go?

You just need add the data annotation validation attribute to the fields or properties of the
ViewModels.

Best Regards

Starain

Hi,

1. Use CSS style, what you want.

2. Custom Data Annotation always good, beco’z you can push your logic into validation.

http://20fingers2brains.blogspot.com/2013/04/custom-annotations-in-aspnet-mvc3-razor.html

Thanks,

Jai.

[RESOLVED]MVC Grid List and details redirect using Web API and Javascript

Using MVC, Web API, and JavaScript Create a website that has the following:

1. Landing page that displays a list of machines (name, description)

2. Each machine has a link to show its details. (Use Asp.Net MVC).

3. Display machine details and let the user enable or disable it (Use Asp.Net Web API).

4. Next to the machine details, show a list of "measurements" for the machine by polling the server every 3 seconds and append the measured information which is returned from the server (random number) to the list. (Use JavaScript + Web API).

Notes: Machines must be persisted in memory, having an initial set of 10 machines.

Data points for each machine don’t have to be persisted. Each machine has the following properties: Id, description and status (enabled, disabled)

Use bootstrap or similar for layout and styling. 

Can someone give me the code for bove or point me to rsources on the web . I am completely new to MVC and any help is welcome

Thanks

ROHITJGC

Can someone give me the code for bove or point me to rsources on the web . I am completely new to MVC and any help is welcome

THis is a basic application. Please see tutorials from http://www.asp.net/mvc

Hi ROHITJGC,

ROHITJGC

1. Landing page that displays a list of machines (name, description)

2. Each machine has a link to show its details. (Use Asp.Net MVC).

You could refer to this article below:

# MVC Music Store

http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-1

ROHITJGC

3. Display machine details and let the user enable or disable it (Use Asp.Net Web API).

Just need to update the record in the database

ROHITJGC

4. Next to the machine details, show a list of "measurements" for the machine by polling the server every 3 seconds and append the measured information which is returned from the server (random number) to the list. (Use JavaScript + Web API).

Using jQuery AJAX to request the data.

ROHITJGC

Notes: Machines must be persisted in memory, having an initial set of 10 machines.

You could store the data in the session

ROHITJGC

Use bootstrap or similar for layout and styling. 

Please refer to:

# Bootstrap Overview

http://getbootstrap.com/css/

You need to try it by yourself, if you have the issues, please create the thread for each issue.

Best Regards

Starain

I have completed the first 2 points 

3. Display machine details and let the user enable or disable it (Use Asp.Net Web API).

First they dont want check boxes but Enable and Disable Buttons , I saw on below site 

http://jameschambers.com/2012/07/bootstrapping-mvc-say-no-to-checkboxes/  but getting error

0x800a1391 – JavaScript runtime error: ‘$’ is undefined

Also  How to use ASP.net Web API to do the edits??????

4. Next to the machine details, show a list of "measurements" for the machine by polling the server every 3 seconds and append the measured information which is returned from the server (random number) to the list. (Use JavaScript + Web API).

I have no idea about polling the server every 3 seconds what does this mean and How to append this information to a list

Hi ROHITJGC,

ROHITJGC

First they dont want check boxes but Enable and Disable Buttons , I saw on below site 

http://jameschambers.com/2012/07/bootstrapping-mvc-say-no-to-checkboxes/  but getting error

0x800a1391 – JavaScript runtime error: ‘$’ is undefined

Also  How to use ASP.net Web API to do the edits??????

For this error, you need to load the jQuery files.

About the issue of Web API, please post it to the
Web API
forum.

ROHITJGC

I have no idea about polling the server every 3 seconds what does this mean and How to append this information to a list

Please refer to:

# JavaScript Timing Events

http://www.w3schools.com/js/js_timing.asp

# jQuery.ajax()

http://api.jquery.com/jquery.ajax/

Best Regards

Starain

[RESOLVED]Load partial view on the right hand side panel of the main view

HI ,

I am having a main view,, which is divided into 2 sections. Leftpanel with links and right panel with a div.

When i click each link in the left side menu it should render the corresponding partial view in the div in the right side panel.

PLease find my code

Main page

@{
    Layout = null;
}
<link href="~/css/Admin.css" rel="stylesheet" />
<!DOCTYPE html>

<html>
<head>
    <meta name="viewport" content="width=device-width" />
    <title>ADMIN PAGE</title>
</head>
<body style="background-color:#bfd0e4;">
     <table style="width:100%;height:100%;">
          <tr style="vertical-align:top;">
               <td style="width:60%">
                       <div id="RenderHere">
                         
                    </div>
                  </td>
               <td class="middletd">
                    <img src="./Images/blue_overlay.jpg">
                </td>
                <td style="width:60%">
                    <div>  
                        <table style="height:60%">
                            <tr>
                                <button id="doctors">Doktori</button>
                                <button id="apointments"> Pregledi</button>
                            
                            </tr>
                        </table>             
                    </div>
                 <div class="holidayinn"><img src="./Images/holiday_club_logo.png"></div> 
            </td>
        </tr>
    </table>
</body>
</html>

Here two buttons are there.

I am having a partial view named _branchpartial.Its a partial view which lists some data from the db which again pouplates modal dialogs.

But here when i clcik the first button it should display this partial view(_branchpartial) in the div "RenderHere". And i need to pass the model also.

In the controller i have already written Actionresult and created partial view as follows

public ActionResult Branch()
        {
            model= new TrackerModel();
             // List<BranchModel> filterdBranchData = null; 
              try
              {
                  model.branchData = this.ppiService.GetBranchData();
                 // filterdBranchData = model.branchData.Where(item => item.IsDisabled.Equals(false)).ToList();
               
              }
              catch (Exception ex)
              {
                  logger.Error("error occured", ex);
              }
              return View(model.branchData);
        }

Please help me to find a solution. I need to open the partial view in the div when i click the first button.

Can i use ajax method? if so how?

How can i call the Action "Branch"  from the button?

Thanks,

Vidya

Please take a look at Ajax.ActionLink. It solves your problem

Ajax.ActionLink and Html.ActionLink in MVC  (please scroll to the middle of the page)

[RESOLVED]How to learn MVC well?

Hi guys ,

    Recently I was asked to handle a project using MVC5. I’m a fresh man of Asp.net , and before I try to learn Asp.net WebForm an exported who has plenty asp.net developing exprience told me that I’d better jump over the traditional WebForm, and start to
learn MVC directly. Well I’ve learned this "http://www.asp.net/mvc/tutorials/mvc-5/introduction/getting-started"  and tried the whole sample. But where should I put my right
foot after that ? I know that I’m still far away from a MVC developer, but what I should learn next ? How many things else I need to know before I can use MVC to build a site like this one ?

Thanks for any suggestion :)

I am currently learning MVC modern framework. Do you have a project at work you are working on? If not, no worries, more time for you to learn on your own (I hope). Please take a peak at the Adam Freeman books. See here: http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Daps&field-keywords=Pro+ASP.NET+MVC+5 I
am currently going through them. It will take time. Most importantly, can you think of a cool custom project you want to do? Even if you don’t know how to code the features. Try to build your idea piece by piece. As many Microsoft developers have commented
on their own tutorials, we should really try to learn by doing. 

I am constantly looking for more tutorials and materials myself. My current challenge is finding decent resources for authentication. Hang in there. :) 

Hlyates, what about authentication are you trying to find resources for? Maybe I can help!

Hey Robin,

An enterprise level MVC application would probably use some of the following:

Client Side:

  • HTML
  • CSS
  • jQuery
  • Javascript
  • Ajax

Server Side:

  • .NET MVC
  • C#
  • SQL
  • Entity Framework

Some other general things that will help along the way:

  • Security
  • Continuous Integration and Deployment
  • Caching
  • Client and Server side debugging tools
  • Unit/Integration/Acceptance testing

I was thinking of creating something that helped people create an Enterprise grade website from scratch. This would help you learn all of the skills, at least at a high level, and also have something to add to your portfolio for jobs.

Does that sound like something you would be interested in/that would be useful?

Steve

Just ask here in the forums if you don’t understand something. And do a lot of research
Smile

stephenmichaelf7

Hlyates, what about authentication are you trying to find resources for? Maybe I can help!

Anything that I can find that is MVC 5. I would like to find source code to study and tutorials. Please read my post

here
. As for making tutorials yourself, yes, anything you would like to share helps. Additionally, any resources to help learn HTML/CSS/JQuery/JavaScript for ASP.NET MVC specifically?

Hi Robin,

Thanks for your post.

Robin20091010

I’m a fresh man of Asp.net

I suggest that you can follow this tutorial:

http://www.asp.net/mvc/tutorials/mvc-music-store and you can download the completed code to learn

Hope this can be helpful.

Best Regards,

Eileen

Hi Steve,

Many thanks 2u man! That’s almost the perfect answer I’m looking for! 

Also I’m thinking about that maybe I need a "more complicated" sample for me to learn to.

Actually in the past few year I’ve majored in Winform development using C#, so I think I’m kinda familiar with C#/MsSql/CI/UnitTest methodoloies,but web developing skills are always my weakness :(    Recently I’ve learned by myself HTML/CSS/Javascript, yet
cannot expertly to use those three. So my question after I finished the "Getting Start Sample" was how to use MVC to create an excellent/good looking page…like some popup dialogs or something else to make it more "professional" , or as "Enterprise grade
" like you said. I have a little experience on WebForm developing, but it doesn’t help me at all. Anyway, thanks for your advise so much!

Have a nice day, thank you again :)

Robin.

Hi Eileen,

Thanks very much.It’s a good suggestion for me. I’ll check it out immediately!!!

Robin.

Hi hlyates,

Thanks very much!

"Do you have a project at work you are working on" — yes, it’s coming soon to me in 1 week :( 

Anyway, I would like to read that book you recommend to me ASAP.

Have a nice day :)

Hey Robin,

The quickest way to get started with design is to use Bootstrap, which is actually included in new MVC projects.

You can find it here:

http://getbootstrap.com/

It sounds like there are two different things you are asking for.

The first is the skill of HTML/CSS/Javascript, and the second is how to design and make things look professional.

While they are related they are also two different things.

What resources have you used for HTML/CSS/Javascript? For design, check out this book:

Design For Hackers

It goes over the main design principles for developers.

Steve

Hello Stephen,

Again, thanks for you suggestion.

Well , I basically learned Front-end developing skills from W3CSchool site and a book "javascript professional", and I tried a lot of tiny demos, but that’s far away to be called professional. I agree with you about " two different things you are asking
for
" and yes, both of those two are my weakness :(  

Maybe I asked that in a wrong way, I think actually I’m wondering if there’re some examples for me to understand how could I create an "enterprising" website with asp.net MVC. 

As you may know, with Asp.net, it’s a little bit easier to create an aspx webform page contains a popup window, or some cool/good-looking things, because the web controllers make it easy to do so. I guess it’s not a good way to develop any web applications
with web controller, but with MVC, eh…I don’t know how to arrange my page at all. The reason I like the artical "Getting started with mvc5" so much is the author introduce me a lot of basic knowledge about MVC through a simple demo. But I still have many
questions about MVC and don’t know what kind of things I need to know deeper for the coming project :( And that’s why I post my question here for help.

Anyway, thank you sooooo much! Have a nice day man :)

Robin.