/    Sign up×
Community /Pin to ProfileBookmark

Can I access any Server control in Javascript function in .Net

  • 1. I want to access a Server control in .net within a Javascript function. I used this method.
  • alert(alter(document.getElementById(‘tbCmpName’).id); still its not working.

    Can any body help me in accessing server side control from client side scripting?

  • 2.

    How can I declare string variables in Javascript?

  • 3.

    And one more question, how can I get the length of a string?

  • Please reply me for these queries.

    Aleem

    to post a comment
    JavaScript

    1 Comments(s)

    Copy linkTweet thisAlerts:
    @so_is_thisDec 26.2006 — 
  • 1. Just because it is .NET does not mean the normal HTTP environment regarding the separation of server and client have been nulified. If you want JavaScript to communicate with the server, you'll have to use Ajax. On the other hand, if you've sent a control object along in the HTML to the client, then the following will work to connect to that object:


  • var obj = document.getElementById('tbCmpName');

    alert(obj.id);

    If such an object is not a clienet control, then such a connection will only be to a normal DOM element and, as such, your interaction with it will be just the usual DHTML interaction.

  • 2. The following are two examples of creating JavaScript string variables:


  • var myvar = "string data";

    var myvar = new String("string data");

  • 3. The length of a string is found as follows:


  • alert(myvar.length);
    ×

    Success!

    Help @indian143 spread the word by sharing this article on Twitter...

    Tweet This
    Sign in
    Forgot password?
    Sign in with TwitchSign in with GithubCreate Account
    about: ({
    version: 0.1.9 BETA 6.13,
    whats_new: community page,
    up_next: more Davinci•003 tasks,
    coming_soon: events calendar,
    social: @webDeveloperHQ
    });

    legal: ({
    terms: of use,
    privacy: policy
    });
    changelog: (
    version: 0.1.9,
    notes: added community page

    version: 0.1.8,
    notes: added Davinci•003

    version: 0.1.7,
    notes: upvote answers to bounties

    version: 0.1.6,
    notes: article editor refresh
    )...
    recent_tips: (
    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @meenaratha,
    tipped: article
    amount: 1000 SATS,

    tipper: @Yussuf4331,
    tipped: article
    amount: 1000 SATS,
    )...