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
Solved

ASP.Net: Please leave my field names alone

Posted on 2006-11-14
6
590 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
  • 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
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…
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

840 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