javascript - How to write jQuery inside of C# -


i need javascript or jquery inside codebehind in c# works should if place inside div. want script inside if else

look @ part id chart2

    <div style="position: absolute; top: 0; left: 0; height: 100%; width: 100%; z-index:0; ">         <asp:literal id="ltrrenderchart" runat="server"></asp:literal>     </div>     <div  id="chart2"style="position: absolute; top: 0; left: 50%; height: 100%; width: 100%; z-index:-1">        <script>$("#chart2").css("z-index",0);</script>         <asp:literal id="ltrrenderchart2" runat="server"></asp:literal>     </div>     <div style="position: absolute; top: 50%; left: 0; height: 100%; width: 100%; z-index:-1;">         <asp:literal id="ltrrenderchart3" runat="server"></asp:literal>     </div>     <div style="position: absolute; top: 50%; left: 50%; height: 100%; width: 100%; z-index:-1;">         <asp:literal id="ltrrenderchart4" runat="server"></asp:literal>     </div>  </div> 

but if write inside if-else not affect anything.

                  else if (n == 2 && chart.width == "50%")                     {                          literal = ltrrenderchart2;                            string script = "<script>$(\"#chart2\").css(\"z-index\",0);</script>";                         scriptmanager.registerclientscriptblock(ltrrenderchart2, ltrrenderchart2.gettype(), "script", script,false);                     }                     else if (n == 2 && chart.height == "50%")                     {                        literal = ltrrenderchart2;                           string str = "<script>$(\"#chart2\").css(\"z-index\",0);</script>";                         scriptmanager.registerclientscriptblock(ltrrenderchart2, ltrrenderchart2.gettype(), "script", str, false);                     } 

does know problem?

thanks

if u write inside c# this:

string script = "<script>$(\"#chart2\").css(\"z-index\",0);</script>"; 

then c# consider string value.

scriptmanager.registerclientscriptblock(this, this.gettype(), "script ", script , true); 

and using scriptmanager, add javascript script page shown above


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -