string clientId = "someId"; string script = @" <script> function DisableButton() { document.getElementById('{0}').disabled = true; } </script> "; script = string.Format(script,clientId);Much easier to write, read and work with. Note that @"" strings have to escape double quotes (") with two double quotes ("").
><script type = "text/javascript"> > function DisableButton() { > > document.getElementById("< %Submit.ClientID %>").disabled = true; > > } > > window.onbeforeunload = DisableButton; ></script> >>
> 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>"); >>
>cstext2.Append("document.getElementById('" + Submit.ClientID + "').disabled = true; }"); >