?
Solved

Types of HTML text boxes when using MVC with .Net

Posted on 2016-08-21
2
Medium Priority
?
47 Views
Last Modified: 2016-08-21
I have two different text boxes below. I am under the impression that they are both HTML text boxes. I am using Microsoft.net,
and MVC with C#.

I want to place these text boxes in a partial view. I have noticed that the <input type ...> text box when used as a partial view will be displayed in every .cshmtl page in the project, and the other text box type @Html will display in only the .cshtml page that uses the partial view. Which text box type is better, and why does one show on all of the .cshtml pages, and the other only on one?


  <div style="padding-left:19px; width:806px;">
        @Html.TextBox("PartialTextBox", "", new { style ="width: 100px;", id="partialBox" })

        <input type="text" name="customer" id="newCust" value="">
    </div>
0
Comment
Question by:brgdotnet
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 1

Accepted Solution

by:
Reece Cottam earned 2000 total points
ID: 41764628
Well essentially your @Html.Textbox is a helper method; I.E, a piece of Razor code which dynamically generates your HTML on the server and then puts it onto a cshtml file for you, the other piece of code you have is just bog standard HTML and works in precisely the same way, if you prefer the Syntax of a helper method then by all means go ahead with that, otherwise use raw HTML :)

As for why the plain HTML is on every single view and @html.Textbox is only present on your partial view presumably is down to the fact that MVC knows which namespace your helper method is in , and so it will render it as part of a partial view, it doesn't know what to do with your plain HTML so it just renders it.
1
 
LVL 2

Author Closing Comment

by:brgdotnet
ID: 41764741
Pretty awesome answer. Thanks.
0

Featured Post

DFW AZURE MEETUP TONIGHT FRI 6PM

We will be discussing what Azure Stack is, how does it fit into the suit of offerings that Azure has currently, and where can it fit into your organizations technology stack. We will also be discussing limitations of the platform while covering various applicable scenarios.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question