Idseparator not set as default

  • Thread starter Thread starter Simon Tuohy
  • Start date Start date
S

Simon Tuohy

Hi,

I am using VS2005 to build a web application. I am currently at the
prototyping stage, so best practices are not so important. I need to refer
to a control on an ASP page from within some Javascript. I am setting the ID
of the masterpage to "Master", so that all my controls are named
Master$Control1 etc. The problem I have is that the serparator is coming
through as a colon (:), not the expected dollar sign. I do not have .net 1.1
installed on my development machine any longer, so I don't think that this
is causing the problem.

Has anyone any ideas as to where this is set?

Many thanks,

Simon
 
Hi Simon,

Thank you for your post.

Based on my understanding, your question is how to determine the control id
in javascript. If I've misunderstood anything, please feel free to post
here.

It is recommended that you do not rely on directly referencing the IDs as
you can see them in the browser. The formula used to generate unique IDs
for child controls is undocumented and can change. Instead, get the value
of the child control's ClientID property and use that value to reference
the child control. For more info, please refer to following MSDN
documentation:

#Client Script in ASP.NET Web Pages
http://msdn2.microsoft.com/en-us/3hc29e2a.aspx#IdentifyingServerControlsInCl
ientScript

Hope this helps. Please feel free to post here if anything is unclear.

Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Thanks for your reply Walter.

I am trying to ascertain why the seperator is a colon on my machine, whereas
according to documentation, it should be a dollar sign under the .net
framework 2.

The only reason we are directly referencing the ID at the moment was for
speed and simplicity (this is just a proof of concept).

Many thanks,

Simon
 
Hi Simon,

Thank you for your update.

I'm afraid the formula to generate unique id of the controls is
undocumented and may change in future version.

You can use following code format to include a control's id in javascript:

<script language="javascript" type="text/javascript">
function test()
{
var id = "<%= label1.ClientID %>";
alert(id);
}
</script>

This will include the control's id dynamically.

Hope this helps. Please feel free to post here if anything is unclear.


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Hi Simon,

Have you tried my suggestion in my last post? Does that meet your
requirement? Please feel free to post here if you need more help on this.

Have a nice day!


Regards,
Walter Wang ([email protected], remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top