SitePoint Sponsor

User Tag List

Results 1 to 10 of 10
  1. #1
    SitePoint Guru
    Join Date
    Dec 2008
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    ClientId of control not obtained

    i have var mycontrol = <%=newcontrol.ClientId%>.id; in my aspx page
    and i have an external .js file
    but by uisng in this way i am not gettiing the clientid of the new control.
    can anybody help

  2. #2
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Norway
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Correct, but you can add it inside the page.
    Code:
    <script type="text/javascript">
        var mycontrol = <&#37;= newcontrol.ClientId %>;
    </script>
    Or from your code-behind.

  3. #3
    SitePoint Guru
    Join Date
    Dec 2008
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    u mean by uding external file we canot do it?
    has this code to be inline only?????

  4. #4
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Norway
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not to the external file but inside the page like I showed in my example.

  5. #5
    SitePoint Guru
    Join Date
    Dec 2008
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i understood wht u meant
    but my full code for this is in external js file
    that particular line is inside a funcion in the external js file
    i cant just take out the single line . i need to take the full function inline

    is it not possile by using external js file????

  6. #6
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Norway
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well then I would try and replace it with a class to identify it instead.

  7. #7
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Norway
    Posts
    715
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But then again it should still work if you just declare it as a public property before you include your external .js file and use that property inside your function.

  8. #8
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by svibuk View Post
    i understood wht u meant
    but my full code for this is in external js file
    that particular line is inside a funcion in the external js file
    i cant just take out the single line . i need to take the full function inline

    is it not possile by using external js file????
    External files do not pass through the asp interpreter, so no, it is not possible to place asp code inside an external js file.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  9. #9
    SitePoint Guru
    Join Date
    Dec 2008
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    hi Paul
    Thanks for your valuable guidance
    i have writtenn that script in the webpage instead of externa js fie and its working now

    it means we cannot use external js file for passig clientid of control
    thanks

  10. #10
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,729
    Mentioned
    104 Post(s)
    Tagged
    4 Thread(s)
    If you don't want the data to be embedded in the web page, perhaps for reasons of security, you can use ajax to pass a request for the data from a server-side script, but that's a topic I suspect for some other occasion.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •