Solved

ASP.Net: Please leave my field names alone

Posted on 2006-11-14
6
593 Views
Last Modified: 2012-05-05
I have a hidden field in my code... One in is an html input field and the other is an asp:hiddenfield object...

Both of them, when I wrote my page, had nice names... When I view the source, ASP.Net has "nicely" changed these names to...

"ctl00$ContentPlaceHolder1$InputCategoryName"

and such like.

How do I get it to leave my code alone?
0
Comment
Question by:Tentux
[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
6 Comments
 
LVL 6

Accepted Solution

by:
DonKyles earned 250 total points
ID: 17949973
I think you are using MasterPage in this application.
"ctl00$ContentPlaceHolder1$InputCategoryName" is the name of that field show on client side.
If you want to use client side script (such as Javascript), you have to use that long name to run the script, for example document.form1.ctl00$ContentPlaceHolder1$InputCategoryName.value

Then only way to get rid of this stupid name is take out the MasterPage.
0
 
LVL 5

Assisted Solution

by:kumar_jac
kumar_jac earned 250 total points
ID: 17955010

Hi,
 If you put it under the container it will change the name. To get that client name of the fields

use the control.ClientID in server side and pass the value to client side and use it in client side

Example

Page1.aspx.cs

btnSubmit.Attributes.Add("onlcik", "Javascript:fnShow(' " + txtName.ClientId + "');" );

in

Page.aspx

Js function

function fnShow(id)
{

        alert(document.getElementById(id).value); //use like this.
}


regards,

Krishna kumar.M
0
 
LVL 6

Expert Comment

by:DonKyles
ID: 17958966
Another way is using header and footer instead of MasterPage.
0
 

Author Comment

by:Tentux
ID: 18323447
Wouldn't have accepted the "Solution" personally. Thanks for forcing it upon me, now I know what I need to do. :P
0

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
Simple Linear Regression
Progress

724 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