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?

What is the practical usage of sharing service contract assemblies in WCF?

Answer by Sharmilli Priyadarsini:

Straight forward answer is, If you do not mark a class/interface as a service contract, it cannot be consumed as the service. The function of service contract is to serialize the class, in order to be consumed from other applications written in various platforms.
A practical example:
Just follow the below steps,
1) File >> New >> Project
2) Select WCF project as shown in the image below.

3) If you open the IService.cs file, you will see the service contract attribute added to your interface.
4) Now set your svc.cs as start page by right clicking and setting it as start up page. If you run your project, WCF test client will open, where you will be able to see the service contract under which the methods written inside it and test the service methods by passing the desired parameters.

Let us come to the actual problem, what happens if we do not have the service contract attribute over the interface?

5) Go to your IService.cs and remove the ServiceContract attribute.

6) While running the project it, the WCF test client throws a error saying that “Failed to add a service. Service metadata may not be accessible. Make sure your service is running and exposing metadata”.

Contracts are meant for serialization purpose. If you want to expose a class/interface, you need to attribute it as service contract.

Hope it solves your query, Happy Learning!

What is the practical usage of sharing service contract assemblies in WCF?

I want to develop a banking site. Where can I find a good tutorial blog or site that explains about the workflow of banking system, datab…

Answer by A Quora admin:

A deep understanding of the banking domain is necessary before looking for the workflow and design of the banking system. This will also provide a deep insight on the terminologies and the things happening in banks that will help us to serve the need of the customer and understand the workflow.
Recommended readings:
1) BFSI – wikipedia page
2) Banking Domain   ,Essential bank domain knowledge for IT professionals
As the banking domain itself is vast, with sufficient knowledge about it, you must be able to derive at the requirements of your banking applications you are planning to develop. Based on the requirements at the high level, your database should be designed.
However, if you are looking for a typical online banking application it will have the following modules:
1) Authentication and Authorization
2) Different level of access and screens for the different roles like a personal/corporate/relationship managers/branch managers/Area managers etc.
3) (Assuming the application handles only the online banking) The customer view that will have the modules for
1) viewing the balance in each of the connected accounts,
2) viewing the transactions (credit and debit)
3) Managing (add/edit/delete details) beneficiaries to whom you want to make transactions,
4) Online transfer
5) The system will be integrated to the core banking solution to make your transactions synchronous with bank database. If the application is integrated with the Core Banking Solution CBS, you need not be concerned more about the database design, instead your focus should be on sending the serialized information that can communicate with the CBS

But, if you are planning to develop a model Banking application, you can also make use of the database design proposed by Harsh Dev and Amit Sen from their research paper “MDA based approach towards Design of Database for Banking SystemPage on ijcaonline.org

Hope it helps.

I want to develop a banking site. Where can I find a good tutorial blog or site that explains about the workflow of banking system, datab…