Using viewbag pass data to the view and bind it to my dropdownlist.

In my booking view I has a dropdownlist need bind to my database table, In this tast I just use viewbag. I know it is good habit bind the view to your viewmodel, but sometime you need do some nasty thing to get the job quickly done. So here is the code in my controller to retrive the data and pass it to the viewbag.

retrevedatafromdatabses

here I pass to SelectLists to my view.

I my view you just need this one line of code to get it.

@Html.DropDownList(“SydneySuburb”, null, “Select »”, new { @id = “to_suburb” })

@Html.DropDownList(“SydneySuburb”, null, “Select »”, new {  @id = “from_suburb” })

the dropdown is look like this

dropdownlistcontroller

Simple isn’t it!!!

First I tried to do this, I search internet, there are expert write it in very complexed way. The expert alway like to write it like that to make them looking like expert( in my view).

here I just figure it out in very simple way.

Have fun!

Advertisements

JQuery Auto complete work with bakcode by using asp.net mvc

Recently to convert the new website, I have a bookinng form for the clients to finished the booking,there is some exiting data need to using auto complete. In the past I alway use ajax tool control kits to achieve that result. But now I am kind of fun for JQuery. Here is the Jquery Autocomplete textbox

First I have databses contain all the subuerbs, here is my database table.

databaseSuburbs

here is my action in my BookController:

databseJasonResult

I let it return json because json is the fast and easy analyse data at moment.

Then in your view , just add the reference to JQuery UI:

autocompleteJqury

You could ignore the timepicker.min.css, and timepicker.min.js, I use it to picker up the time, for autocomplete don’t need those two references.

here just in you view you just need one more line.

@Html.TextBox(“SearhToSuburb”, null, new {type=”text”,@class=”form-control”, @id = “search_to_suburb” })

That’s it. Simply isn’t it. Have fun. Below is what will it looking like.feels

Royale Coach – ASP.net MVC website Royale Airport Shuttle Transfers

Recently task is to convert the one of old version of our company webstie to asp.net mvc website.The old version has been done by using tranditional asp. And the appearance also don’t looking good.

The new version detective it is desktop or mobile, so the navigation and the contact page will display different in mobile device open it.

Finally get a new appearance done. And hosting it in windows Azure, I have done the most important part.The Book page will have all the function, this still in proceeding.

Here is the first Windows Azure website build by using asp.net mvc, Bootstrap,jQuery,the contact form validation using Ajax. (the booking page In proceeding)
http://royaleapp.azurewebsites.net/

royaleCoach

Using two Way Adding “active” tag to your navigation list in an asp.net mvc Layout page

Recently my task need convert this website http://www.royalecoach.com.au/royale.asp (this is wrote by using classic asp) into asp.net MVC.

First I need to create a layout.cshtml for my the new version of this website.Then navigation need add a class named active to it when the action method has been called.

The first way is very simpley, you could wirte a logic to your view, here is one solution:

addClassNametoLi

But the rule of MVC is the view must be simply as possible, I don’t like this nasty and yuck c# code sit in there. So there is a way just by write a CustomHtmlHelpers to improve it.

here is my class file:

htmlHelper

 

Then in your layout page ,your could use it like:

layoutMenu

That’s it. By the way, I am using asp mvc4. Hope that could help some one else.

Have fun:)

End to end web app in under an hour–Part 1

Jeremy Howard

Here is the video tutorial that goes with this post:

Here’s how to create a complete web app in under an hour. We will (naturally!) create a todo app. The features:

  • Create, update, delete a todo
  • Sort (and show sort order)
  • Search
  • Pagination

We’ll try to make it somewhat user friendly, e.g.

  • Date-picker widget for todo due date
  • Enable/disable buttons as appropriate for context

Our infrastructure will be:

  • Backend Language: C#
  • Backend Framework: WebApi
  • Database: SQL Server (including SQL Express LocalDB during development)
  • ORM: Entity Framework Code First + Migrations
  • Frontend Framework: AngularJS
  • CSS styles: Bootstrap
  • IDE: Visual Studio + Resharper
  • Hosting: Appharbor

As you’ll see, this particular choice of tools is well suited to rapid application development, and is also very flexible.

The goal is not just to throw together the minimal necessary to have something working, but to create a really flexible infrastructure that we can use as…

View original post 1,127 more words