English 中文(简体)
更新面板内的JavaScript
原标题:javascript inside updatepanel
  • 时间:2010-02-25 06:23:32
  •  标签:
  • asp.net

我在ASP.NET GridView中使用JavaScript。

<script type="text/javascript"> 
      var currentRowId = 0;    
      function SelectRow()    
        {     
          if (event.keyCode == 40)     
          MarkRow(currentRowId+1);  
          else if (event.keyCode == 38)
          MarkRow(currentRowId-1);    
        }           
     function MarkRow(rowId)  
        {        
         if (document.getElementById(rowId) == null)           
         return;                   
         if (document.getElementById(currentRowId) != null )  
         document.getElementById(currentRowId).style.backgroundColor =  #ffffff ;   
         currentRowId = rowId;       
         document.getElementById(rowId).style.backgroundColor =  #ff0000 ;  
        }     
    </script>
    <script type="text/javascript">
   var TargetBaseControl = null;   
   window.onload = function()
   {
      try
      {
         //get target base control.
         TargetBaseControl = 
           document.getElementById( <%= this.GridView1.ClientID %> );
      }
      catch(err)
      {
         TargetBaseControl = null;
      }
   }
   function TestCheckBox()
   {              
      if(TargetBaseControl == null) return false;

      //get target child control.
      var TargetChildControl = "chkSelect";

      //get all the control of the type INPUT in the base control.
      var Inputs = TargetBaseControl.getElementsByTagName("input"); 

      for(var n = 0; n < Inputs.length; ++n)
         if(Inputs[n].type ==  checkbox  && 
            Inputs[n].id.indexOf(TargetChildControl,0) >= 0 && 
            Inputs[n].checked)
          return true;        

      alert( Select at least one checkbox! );
      return false;
   }
    </script>

纽扣控制:

Width="80px" CssClass="button" /> 的中文翻译是:“宽度=“80像素”CSS类=“按钮”/ & gt;”。

我在GridView中使用Ajax更新面板...我控制回发级别,但是脚本在更新面板中无法运行。

问题回答

在您的button_clicked事件中,您可以使用此方法。

 ScriptManager.RegisterClientScriptBlock(Control, Type, String, String, Boolean)

以下更多信息





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

How to Add script codes before the </body> tag ASP.NET

Heres the problem, In Masterpage, the google analytics code were pasted before the end of body tag. In ASPX page, I need to generate a script (google addItem tracker) using codebehind ClientScript ...

Transaction handling with TransactionScope

I am implementing Transaction using TransactionScope with the help this MSDN article http://msdn.microsoft.com/en-us/library/system.transactions.transactionscope.aspx I just want to confirm that is ...

System.Web.Mvc.Controller Initialize

i have the following base controller... public class BaseController : Controller { protected override void Initialize(System.Web.Routing.RequestContext requestContext) { if (...

Microsoft.Contracts namespace

For what it is necessary Microsoft.Contracts namespace in asp.net? I mean, in what cases I could write using Microsoft.Contracts;?

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签