Difference between @html.TextBox and @html.TextBoxFor

Difference between @html.TextBox and @html.TextBoxFor.

My answer on Quora:

In abstract terms, the difference between the html helpers @html.TextBox() and @html.TextBoxFor() are the former is weakly typed and is independent of model and the latter is strongly typed and it should be bound to one of the model property in strongly typed view.

Consider the below piece of code,

This will be rendered as shown in the below image.

When you use, TextBoxFor, while the HTML is generated, it will automatically map the value from the model property to it, in the above case “UserName” . So when you post the values of the current page, if your controller is having your model as the parameter, the value can be retrived directly by accessing the property.

When you look at the above screenshot, the model will not hold the weekly typed “simpleTextBox”.

Hope you find it useful.

Can any one explain me the difference between @html.TextBox() and @html.TextBoxFor() in ASP.net MVC?

Model Binding and Strongly Typed Views

Model Binding and Strongly Typed Views

Answer by Sharmilli Priyadarsini:

In order to demonstrate model binding, I am making use of the default scaffold for Account registration available when you create a new web application with Visual studio.

Let us see how to create a strongly typed view using the below model,

Now, from your solution explorer, expand the controller folder and open the AccountController.

You will find something like the below action method,

Right clicking near the ActionResult and selecting go to view will navigate you to the Register.cshtml view which is strongly typed with “RegisterViewModel”. In order to make a view strongly typed, you can either do it through api or marking the model on the top of page as shown below:

Doing, so will generate you a strongly typed view as Register.cshtml bound to RegisterViewModel inside the accounts folder in views.

This is how you can create a strongly typed view. Now let us get into the detail of how to design your view by making use of the above model.When you take a close look of the above screenshot, you will see set of html helpers i.e all that follows “@html.” are said to be html helpers. Why because, they will generate the equivalent html to generate your web pages.

Let us take the below example
@html.LabelFor(m=>m.UserName, new{@class=”my-label”})
@ in the above line of code is known as razor syntax. Everything that follows the razor syntax will be rendered at the web server and are C# code in the .cshtml page and vb code in .vbhtml respectively.
html. represents that a html helper so the equivalent output will be a html code generated by the web server. we have different types of helpers like html helper, ajax helper etc.

LabelFor will generate a html label with the name user name which is strongly typed. But usually the label’s will not post the values to controllers they are just plain text. But if we have other controls like textbox, checkbox we can retrive their values in the controller.

Hope this clears your doubt.

I am getting quite confusion in binding the model data in view page, can any one explain me? How exactly it is done?

துயிலெழு பெண்மையே ! (Wake-up Womankind)

பிறர் ஏவல்செய்ய,
கைப்பாவை வேடம் போட்டாய்,
பிற்போக்கு சமுதாயம் பிழைசொல்லுமென்பதலா?
அவன்சொன்னான்! இவன்சொன்னான்! எவன்சொன்னல் உனக்கென்ன?
உன்கனவும், உன்னுயர்வும் உனக்கு மட்டும் சொந்தமில்லை,
யுகயுகமாய் அடிமைப்பட்ட உலகமகளிர் உயர்வதற்கு உண்பங்காய் இருந்திடட்டும்!

ஒழுக்கமற்ற உலகமிது,
நெறிகெட்ட பாகுபாட்டுப் புதையலிது!
ஈவிரக்கம் இங்கில்லை,(அது) உனக்கு மட்டுமெதற்கு?
பழுதடைந்த பண்பாடு அதன்பெயரில் அடிமைத்தனம் அனுமதியோம்!
கலவுபோனதோ மறுக்கப்பட்டதோ உன் சுதந்திரம், கொடுக்கப்படவில்லையேல் எடுத்துக்கொள்!

(Translation in English)
Hey Womankind,
Don’t be a puppet that others want you to be!
Wake up to live your dream that inspire yourself,
and the oppressed gender!
Hey Womankind,
The world is unfair and unjust,
show no mercy,
If freedom is stolen or denied, take it,
because it is yours!

What certification courses should be done if one wants to have a career as an ASP.Net developer? And in what sequence should they be appr…

Answer by Sharmilli Priyadarsini:

In my opinion,Certification does not count much. If you want to be a good ASP.NET developer , Just start mastering the skills instead concentrating on the certification. ASP.NET is evolving at a faster rate, every release is pooled up with new features. Its not just ASP.NET webforms, its much more we need to build up the profeciency on. We have MVC, vNext (Kathana), OWIN, SignalR. Now that ASP.NET becomes an opensource, so many OS frameworks are supported and so to be on the track, we constantly need to learn things. At least for an extend that we should be able to understand the basics of it. And yes, we need to build quality stuff, using the best practices while we develop stuff. After you have a minimum experience of 6 months to 1 year, take the certification in the area you are comfortable on. All the best!

What certification courses should be done if one wants to have a career as an ASP.Net developer? And in what sequence should they be appr…

How do I popularize my blog on the web?


Answer by Sharmilli Priyadarsini:

This question is the answer, hope your stats are booming 🙂

  1. Marketing your blog to the right audience is the straight forward way to popularise your blog.
  2. But in order to have steady rise in the hits, you need to work on the content quality and how unique your solutions to the problems are.
  3. SEO does the magic for sure. Though you will get huge volume of books on doing Search Engine Optimization , the logic behind is simple more hits to your blog will bring up your content during search, palgiarism will tend to void your content authenticity, so take almost care in avoiding it, quality of content plays an important role. Apart from the above, there is one shortcut, before writing a blog do a research on most used search terms and least used search terms on your topic. And try to use search terms in your post. This will give you a better visibility in search engines. Next thing is try to make use of the most used search terms in the title of the content that makes your blog url connected to the topic, which is directly proportional to search engines ranking. Medium used search keys in tags and least used search keys in your content along with the mix of most used keywords.

This will, for sure bring your blog’s popularity. Happy blogging!

How do I popularize my blog  http://zoomblastic.blogspot.in/ on the web?