调用javascript函数的问题 [英] problem with calling javascript function

查看:64
本文介绍了调用javascript函数的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<script type="text/javascript">
    var SelectedRow = null;
    var SelectedRowIndex = null;
    var UpperBound = null;
    var LowerBound = null;
    
    window.onload = function()
    {
        UpperBound = parseInt('<%= this.gridView.Rows.Count %>') - 1;
        LowerBound = 0;
        SelectedRowIndex = -1;        
    }
    
    function SelectRow(CurrentRow, RowIndex)
    {        
        if(SelectedRow == CurrentRow || RowIndex > UpperBound || RowIndex < LowerBound) return;
         
        if(SelectedRow != null)
        {
            SelectedRow.style.backgroundColor = SelectedRow.originalBackgroundColor;
            SelectedRow.style.color = SelectedRow.originalForeColor;
        }
        
        if(CurrentRow != null)
        {
            CurrentRow.originalBackgroundColor = CurrentRow.style.backgroundColor;
            CurrentRow.originalForeColor = CurrentRow.style.color;
            CurrentRow.style.backgroundColor = '#DCFC5C';
            CurrentRow.style.color = 'Black';
        } 
        
        SelectedRow = CurrentRow;
        SelectedRowIndex = RowIndex;
        setTimeout("SelectedRow.focus();",0); 
    }
    
    function SelectSibling(e)
    { 
        var e = e ? e : window.event;
        var KeyCode = e.which ? e.which : e.keyCode;
        
        if(KeyCode == 40)
            SelectRow(SelectedRow.nextSibling, SelectedRowIndex + 1);
        else if(KeyCode == 38)
            SelectRow(SelectedRow.previousSibling, SelectedRowIndex - 1);
            
        return false;
    }
    </script>


我想在后台代码中调用此功能.当我在rowcreated事件中调用此函数时:


i want call this funtions in code behind.when i call this function in rowcreated event:

if (e.Row.RowType == DataControlRowType.DataRow)
        {
            e.Row.Attributes["onmouseover"] = "this.style.cursor='pointer';this.style.textDecoration='underline';";
            e.Row.Attributes["onmouseout"] = "this.style.textDecoration='none';";
            e.Row.ToolTip = "Click to select row";
            e.Row.Attributes["onclick"] = this.Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex);
          e1.Row.Attributes["onkeydown"] = this.Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select$" + e.Row.RowIndex);
            string js = "if (event.keyCode == 13) this.Textbox1.Text=\"kkk\";";
       this.Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, \"Select$\" + e.Row.RowIndex);";
        GridView1.Attributes.Add("onkeydown", js);
       }
 then it works it navigate gridview.
 following code in selectindexchanged event
TextBox1.Text = GridView1.SelectedRow.Cells[1].Text;

bt无效,但所选行未显示在文本框中.... so帮助我如何调用javascript函数...?

bt it not works mns selected row not displaying in textbox.....so help me how to call javascript function...?

推荐答案

" + e.Row.RowIndex); e1.Row.Attributes [" ] = .Page.ClientScript.GetPostBackClientHyperlink( this .GridView1,"
" + e.Row.RowIndex); e1.Row.Attributes["onkeydown"] = this.Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, "Select


" + e.Row.RowIndex); 字符串 js = " ; .Page.ClientScript.GetPostBackClientHyperlink( .GridView1,\ "
" + e.Row.RowIndex); string js = "if (event.keyCode == 13) this.Textbox1.Text=\"kkk\";"; this.Page.ClientScript.GetPostBackClientHyperlink(this.GridView1, \"Select


\" + e.Row.RowIndex);"; GridView1.Attributes.Add(" ,js); } 然后它可以在gridview中导航. 中的以下代码 已更改事件 TextBox1.Text = GridView1.SelectedRow.Cells [ 1 ].Text;
\" + e.Row.RowIndex);"; GridView1.Attributes.Add("onkeydown", js); } then it works it navigate gridview. following code in selectindexchanged event TextBox1.Text = GridView1.SelectedRow.Cells[1].Text;

bt无效,但所选行未显示在文本框中.... so帮我如何调用javascript函数...?

bt it not works mns selected row not displaying in textbox.....so help me how to call javascript function...?


这篇关于调用javascript函数的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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