Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Building ClientScript in ASP.NET code behind
Message
 
 
À
Tous
Information générale
Forum:
Javascript
Catégorie:
Autre
Titre:
Building ClientScript in ASP.NET code behind
Divers
Thread ID:
01610776
Message ID:
01610776
Vues:
37
Hi,

I am trying to build in the code behind of an ASP.NET page the following Javascript function:
<script type = "text/javascript">
            function DisableButton() {

                document.getElementById("< %Submit.ClientID %>").disabled = true;

              }

              window.onbeforeunload = DisableButton;
</script>
I want to "translate" this code into the Client Script built in code behind. But I get error on the
                    String csname2 = "ButtonClickScript";
                    Type cstype = this.GetType();

                    // Get a ClientScriptManager reference from the Page class.
                    ClientScriptManager cs = Page.ClientScript;

                    StringBuilder cstext2 = new StringBuilder();

                    cstext2.Append("<script type=\"text/javascript\"> function DisableButton() {");
                    cstext2.Append("document.getElementById("< %=Submit.ClientID %>").disabled = true};";
                    cstext2.Append("window.onbeforeunload = DisableButton;");
                    cstext2.Append("</script>");
But I get syntax error on the line
document.GetElementByID... that "missing semicolon".
Could you see how to write this line? Please keep in mind that the actual code has Percent sign (%) instead of work Percent.

UPDATE:
Solution:
cstext2.Append("document.getElementById('" + Submit.ClientID + "').disabled = true; }");
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform