如何从代码注册javascript [英] how to register javascript from code behind

查看:78
本文介绍了如何从代码注册javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是用于注册javascript但无效的代码。

below is code which is used to regsiter javascript but is not working.

protected void Page_Load(object sender, EventArgs e)
       {

            string scriptTest = @"
                               <script type='text\javascript'>
                                    $(document).ready(function(){
                                               alert('in code');
                                               $.jqplot.config.enablePlugins = true;
                                               var s1 = [2, 6, 7, 10];
                                               var ticks = ['a', 'b', 'c', 'd'];

                                               plot1 = $.jqplot('Div1', [s1], {
                                                   // Only animate if we're not using excanvas (not in IE 7 or IE 8)..
                                                   animate: !$.jqplot.use_excanvas,
                                                   seriesDefaults:{
                                                       renderer:$.jqplot.BarRenderer,
                                                       pointLabels: { show: true }
                                                   },
                                                   axes: {
                                                       xaxis: {
                                                           renderer: $.jqplot.CategoryAxisRenderer,
                                                           ticks: ticks
                                                       }
                                               },
                                            highlighter: { show: false }
                                           });

                                           $('#Div1').bind('jqplotDataClick',
                                               function (ev, seriesIndex, pointIndex, data) {
                                                   $('#info1').html('series: '+seriesIndex+', point: '+pointIndex+', data: '+data);
                                               }
                                           );
                                               });</script>";
           string script = "<script type=\"text/javascript\"> alert('hi'); </script>";

           ScriptManager.RegisterStartupScript(this.Page, GetType(), "ClosePopup", scriptTest, false);
       }



请建议解决方案。

谢谢


please suggest solution.
Thanks

推荐答案

(document).ready(function(){
alert('in code');
(document).ready(function(){ alert('in code');


.jqplot.config.enablePlugins = true;
var s1 = [ 2,6,7,10];
var ticks = ['a','b','c','d'];

plot1 =
.jqplot.config.enablePlugins = true; var s1 = [2, 6, 7, 10]; var ticks = ['a', 'b', 'c', 'd']; plot1 =


.jqplot('Div1',[s1],{
//如果我们不使用excanvas(不在IE 7或IE 8中),则只有动画..
动画:!
.jqplot('Div1', [s1], { // Only animate if we're not using excanvas (not in IE 7 or IE 8).. animate: !


这篇关于如何从代码注册javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆