.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Can you have control over the names of HTML elements?

Posted By:      Posted Date: October 08, 2010    Points: 0   Category :ASP.Net


I was just wondering, is it possible to have control over the name of an HTML element that's bound to a property of a viewmodel? For example, if I had a viewmodel with a property called ProductDescription, is it possible to have a text input in the view with the name "desc" instead of "ProductDescription" and somehow tell MVC that "desc" binds to ProductDescription?

Not a big issue, but it would be nice to have control over how my HTML elements are named.


View Complete Post

More Related Resource Links

corrupt html from custom control on win2003/iis6 box


Hello everyone -- first time poster and relative newcomer to the boards.  This bug I'm tackling has me at my wits' end and it's come time to turn to the masses!  If this is posted in the wrong forum and/or has already been addressed, I apologize.  However, I've done thorough searches and haven't come across anything akin to what I'm facing.

I'm working with a website that has a set of custom controls, all descending from a base class.  These controls take DataSets returned from web services and renders custom html via overriding the Render method.  Everything works fine on my local box and my coworker's box (both xp machines running iis 5).  However, on our server (windows server 2003, 64-bit, iis 6), the html rendered by the browser appears corrupt, with garbage replacing individual characters, as follows:


How to reference a elements of one control from other


Can someone explain how user controls can communicate with each other within an asp.net application. I am facing many obstacles at the moment regarding this problem. For example, is it possible to set the visible property of a panel on one user control based on what happens in another?

Another example would be: Can I set the text of a label in one control to be the value of some other property from another control's class like.... Me.PreContentColumn.ColumnID = LocalProduct.PreContentColumnId.

Please let me know if this sounds confusing...

How to create a new Html control which contain multiple html control ?


Hi all,

I am realizing a table with multiple rows for a Sharepoint webpart.

In this project, I would like to have a new html control which contain a LinkHtml in one column and another label in another column.

Essentially this html control would be a row used for my html table.

At the moment i am doing a row like this in the main class :

HtmlTableRow Row = new HtmlTableRow();

            //create colum 1
            HtmlTableCell _Column11 = new HtmlTableCell();
            _Column11.Style.Add(HtmlTextWriterStyle.Width, linkColumnWidth);

            // Create the input textbox
            Label _LinkButton = new Label();
            //_LinkButton.ID = claimsLinkButtonID + contentLabel;
            //_LinkButton.CommandName = IdTask;
            _LinkButton.Text = contentLink;
            //_LinkButton.Style = 

            Label _NumberOfMessagesLabel = new Label();
            _NumberOfMessagesLabel.Text = contentLabel;

            //add the textbox into column 1

            //add column 1 into row 1

            //create column 2
            HtmlTableCell _Column12 = new HtmlTableCell();
            _Column12.Style.Add(HtmlTextWriterStyle.Width, priorityColumnWidth);

            // add the label into colu

Get the value of hiddenField HTML control not work properly in FireFox


Hi Guys,

I'm trying to access the the value of Hidden field as follows:

var empID= document.getElementById('HiddenField1').value;

It works well in IE but gives null in FireFox

WPF- Back/Forward navigation UI not working when Html web files are displayed in Frame Control


I am integrating (web) html files in my WPF application using Frame (say Source=http://www.microsoft.com)

I set the JournalOwnership="OwnsJournal" and


The navigation UI is visible and disabled initially when the page loads up (which is fine), but when I click on links the Back/Forward button is not enabled.  Interestingly the context menu shows Back/Forward and I can navigate that way. Do you have pointers?


Thanks for your help.

I need to Group Elements in Nested Repeater Control



User Group Management
User Groups Add  Delete   Edit  View  Activate/Deactivate  Export
User Management

Changes to Properties in the Property Window not Updating in HTML Control


I'm using VWD 2010 Express and have found that when I change a property like AutoPostBack from within the property window the corresponding tag (<asp:TextBox...>) was not updated with the property change to the tag.

Is there a setting that I can change in the VWD properties that will enable changes through the property window for a control to automatically update the HTML tag for that control?

Call server control from HTML string


Hi you guys, is there any way to create a server control from html string, i mean in code behind i have a string like this:

string html = "<asp:CheckBox ID=\"CheckBox1\" runat=\"server\" />";

So how to insert it into aspx page and when the page is rendering, it convert my string as i write it own in the webpage
Hope you guys can help
Thanks in advance!

controling html elements in controler's code


Hi. I'm starting to learn mvc2, mainly because my job requires it.

I had a doubt, that even silly is driving me nuts.  I pick up on the nerddinners examples, following Professional.ASP.NET.MVC wrox book.
but now i'm doing some modifications for my own account.
On traditionl ASP.net it was possible to interact with html elements (divs, textbox, etc... )
On MVC 2 is that possible or any interaction with html must be done with jquery and how?  Because i'm trying to manipulate an html element on my Controller page (DinnerController.ASPX and i had no reference to html div, as i initially supose. 


WCF client for axis2 web service (same element names for different elements in different complex typ



we want to consume a axis2 web wervice. We can't influence the web service definition.

the wsdl looks like:

<?xml version="1.0" encoding="utf-8"?>
        <xs:element name="BAPI_COMPANYCODE_GETLIST">
            <xs:element minOccurs="0" maxOccurs="1" name="OUTPUT">
                  <xs:element minOccurs="0" maxOccurs="1" name="RETURN" type="psi:BAPIRETURN">

handling html server control events


How to wire up HTML server controls events?

I added a Input (Text) control in my web form and turned it into an HTML server control so its an instance of HtmlInputText class.

If I double click on the control It only adds a OnClick event handler method inside the script tags in the HTML doc of the web form but how to I get to handle its Serverchange event exactly? does VS.net 2008 has no ability to auto wire up the event to the control, do I have to manually wire up the event handler?

Printing A List of Control Names On Webform


Hi All,


I have a Webform with a large number of user controls on it, they were auto generated as part of a formview.

I would like a way (Add in etc) to print a list of all of the names of the controls for me to use for the code, rather than having to go through and write them all down.

does anyone know of an add in or an easy way to do this in VS2010..?




opaquness of html elements


I have a web page with the following css code..

<style type="text/css">
  width: 500px;
  height: 250px;
  background: url(klematis.jpg) repeat;
  border: 2px solid black;
  width: 400px;
  height: 180px;
  margin: 30px 50px;
  background-color: #626469;
  border: 1px solid black;
  width: 300px;
  height: 135px;
  margin: auto;
  position: relative;
  top: 10%;
  background-color: #ffffff;
  border: 1px solid black;
div.trans p
  margin: 10px 10px;
  font-weight: bold;
  color: #000000;
<body><div class="background">
<div class="transbox">
<div class="trans">
<p>This is some text that is placed in the transparent box.
This is some text that is placed in the transparent box.
This is some text that is placed in the transparent box.

Even if the opacity of the "trans" class is set to 1, i was able to see the background image.

Can someone suggest me how to make it completely opaque.


how to convert simple html to asp.net control( server side useing C#,Jquery,xml,xslt)


input form 
<FORM METHOD=POST ACTION="mailto:someone@$nailmail.com" ENCTYPE="text/plain"> <table border=0 cellspacing=0 cellpadding=2> <tr> <td colspan=2> <font size=2 face="arial" color="#000000"> <INPUT type="text" name=URL size=17 value="http://"> :Your URL<BR> <INPUT type="text" name=user size=17> :Your Username<BR> <INPUT type="text" name=email size=17> :Your E-mail </font> </td> </tr> <tr> <td> <font size=1 face="arial" color="#000000"> <INPUT name=subscribe type=radio value="yes" CHECKED> subscribe<BR> <INPUT name=subscribe type=radio value="no"> unsubscribe<BR> </font> </td> <td> <SELECT name="choices" size=1> <OPTION selected> OPTIONS <OPTION> OPTION 1 <OPTION> OPTION 2 <OPTION> OPTION 3 <OPTION> OPTION 4 <OPTION> OPTION 5 </SELECT> </td> </tr> <tr> <td colspan=2> <font size=1 face="arial" color="#000000"> <INPUT type=checkbox name="html" value="sendme" CHECKED> i can recive email as html<BR> <INPUT type=checkbox name="receipt"

Method structure like this Html.Control().Name("Grid1").Pageable().Sortable().Filterable().Groupable



I have a question about building method structure

I use a 3th party control and i like the way off adding or appending functionality to some control.

Here is an example:

 Html.SomeControl() .Name("Grid1").Pageable().Sortable().Filterable().Groupable().Render();

What i like is that you can call for example sortable first and then pageable.

Now how do you build something like this.

I create a class and create several methods. But the thing is you can only select 1 method. after that only the tostring is selectabel.

Can somebody help me out on this






Le Moustique

Render User Control with Events in html


I have to render a user control in html. Say, I have a page called AboutUs.aspx and I am feeling that content from admin section in an html editor.
I have a control called, "Contact Us" and this control I am creating dynamically by adding controls like TextBox, Dropdownlist etc.
Now, I want to render this control in my html. I can use something like [contactus] in html and render it like,

Creating dynamic elements in an html table


I need to create 3 buttons in addition to 2 text values (which come out fine) in a row for a table.

However, the buttons are coming out as straight input text fields even though I specifiy  "button" as the type for the td attribute.

Below is my js.

How can I set up these buttons as actual buttons instead of input text fields? Notice the boldfaced code below which is coming out as just input text boxes instead of buttons.

    var tr = document.createElement('tr');
    var td1 = document.createElement('td');
    var td2 = document.createElement('td');
    var td3 = document.createElement('td');
    var td4 = document.createElement('td');
    var td5 = document.createElement('td');

    //Up button

Users Add  Delete EditViewActivate/DeactivateExport
Roles Add  Delete EditViewActivate/DeactivateExport
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend