| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 6798 人关注过本帖
标题:.net后台的函数怎么调用JS里的变量值啊?
只看楼主 加入收藏
lmyh5201
Rank: 1
等 级:新手上路
帖 子:241
专家分:0
注 册:2007-3-29
结帖率:100%
收藏
 问题点数:0 回复次数:9 
.net后台的函数怎么调用JS里的变量值啊?
后台有一个函数,我想把js里的变量值传过来,怎么传阿?
代码如下:JS代码:
function openDiv3(id)
    {
        var txt_ID=id.id;
        sWidth=document.body.offsetWidth;
        sHeight=screen.height;
        
        var bgObj=document.getElementById('divBG3');
        bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=2,opacity=25,finishOpacity=75";
        bgObj.style.opacity="0.5";
        bgObj.style.width = sWidth;
        bgObj.style.height = sHeight;
        bgObj.style.display="inline";
        
        var bgObjCtrl = document.getElementById('divCtrl3');
        bgObjCtrl.style.width = sWidth;
        bgObjCtrl.style.display="inline";
        document.all("objb4").disabled=true;
        
    }
txt_ID就是我要的变量
后台有一个函数 getinfo 我怎么得到txt_ID的值呢?
搜索更多相关主题的帖子: 变量 后台 函数 
2008-09-26 13:49
kevintang
Rank: 4
等 级:业余侠客
威 望:9
帖 子:799
专家分:236
注 册:2008-2-14
收藏
得分:0 
那你把这个值 放在隐藏域中!
   把隐藏域 加个RUNAT= SERVER 不就可以取到了吗?

编程少年基地——少年编程者的练兵场
http://bcsn.    招聘版主中

2008-09-26 14:35
lmyh5201
Rank: 1
等 级:新手上路
帖 子:241
专家分:0
注 册:2007-3-29
收藏
得分:0 
给点代码

2008-09-26 14:38
lmyh5201
Rank: 1
等 级:新手上路
帖 子:241
专家分:0
注 册:2007-3-29
收藏
得分:0 
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Blog_Photo_User_List.aspx.cs" Inherits="img_Blog_Photo_User_List" %>
<%@ Register Assembly="AspNetPager" Namespace="Wuqi.Webdiyer" TagPrefix="webdiyer" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.

<html xmlns="http://www. >
<head runat="server">
    <title>用户相册</title>
    <script type="text/javascript" language="javascript">
    function openDiv()
    {
      
        sWidth=document.body.offsetWidth;
        sHeight=screen.height;         
        
        var bgObj = document.getElementById('divBG');
        bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=2,opacity=25,finishOpacity=75";
        bgObj.style.opacity="0.5";
        bgObj.style.width = sWidth;
        bgObj.style.height = sHeight;
        bgObj.style.display="inline";
        
        var bgObjCtrl = document.getElementById('divCtrl');
        bgObjCtrl.style.width = sWidth;
        bgObjCtrl.style.display="inline";
        document.all("objb1").disabled=true;
        
    }
    function closeDiv()
    {
        divBG.style.display="none";
        divCtrl.style.display="none";
        document.all("objb1").disabled=false;
    }
   
    function openDiv1()
    {
        sWidth=document.body.offsetWidth;
        sHeight=screen.height;
        
        var bgObj=document.getElementById('divBG1');
        bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=2,opacity=25,finishOpacity=75";
        bgObj.style.opacity="0.5";
        bgObj.style.width = sWidth;
        bgObj.style.height = sHeight;
        bgObj.style.display="inline";
        
        var bgObjCtrl = document.getElementById('divCtrl1');
        bgObjCtrl.style.width = sWidth;
        bgObjCtrl.style.display="inline";
        document.all("objb2").disabled=true;
    }
   
    function closeDiv1()
    {
        divBG1.style.display="none";
        divCtrl1.style.display="none";
        document.all("objb2").disabled=false;
    }
   
    function openDiv2()
    {
        sWidth=document.body.offsetWidth;
        sHeight=screen.height;
        
        var bgObj=document.getElementById('divBG2');
        bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=2,opacity=25,finishOpacity=75";
        bgObj.style.opacity="0.5";
        bgObj.style.width = sWidth;
        bgObj.style.height = sHeight;
        bgObj.style.display="inline";
        
        var bgObjCtrl = document.getElementById('divCtrl2');
        bgObjCtrl.style.width = sWidth;
        bgObjCtrl.style.display="inline";
        document.all("objb3").disabled=true;
    }
   
    function closeDiv2()
    {
        divBG2.style.display="none";
        divCtrl2.style.display="none";
        document.all("objb3").disabled=false;
    }
   
    function openDiv3(id)
    {
        var txt_ID=id.id;
        
        sWidth=document.body.offsetWidth;
        sHeight=screen.height;
        
        var bgObj=document.getElementById('divBG3');
        bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=2,opacity=25,finishOpacity=75";
        bgObj.style.opacity="0.5";
        bgObj.style.width = sWidth;
        bgObj.style.height = sHeight;
        bgObj.style.display="inline";
        
        var bgObjCtrl = document.getElementById('divCtrl3');
        bgObjCtrl.style.width = sWidth;
        bgObjCtrl.style.display="inline";
        document.all("objb4").disabled=true;
    }
   
    function closeDiv3()
    {
        divBG3.style.display="none";
        divCtrl3.style.display="none";
        document.all("objb4").disabled=false;
    }

    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <table id="Table1" cellspacing="0" cellpadding="0" width="100%" border="0">
                <tr>
                    <td class="TopNvar">
                        <table id="toptab" runat="server" width="100%" cellspacing="0" cellpadding="0" border="0">
                            <tr>
                                <td>
                                    <a href="Blog_Photo_User_List.aspx">相册</a>
                                </td>
                                <td>
                                    <a href="Blog_Photo_User_Inser.aspx">上传照片</a>

                                </td>
                            </tr>
                        </table>
                    </td>
                </tr>
                <tr>
                <td >&nbsp;
                </td>
                </tr>
               
                <tr>
                    <td style="height: 572px">
                        <table class="ContentBorder" cellspacing="0" cellpadding="0">
                            <tr>
                                <td valign="top">
                                    <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
                                        <asp:View ID="View1" runat="server">
                                            <div style="width: 100%;">
                                                <div style="width: 15%; float: left;">
                                                    <div style="height: 20px;">
                                                        &nbsp;</div>
                                                    <div style="width: 100%; padding-left: 10px;">
                                                        <asp:Literal ID="lr_catalog" EnableViewState="false" runat="server"></asp:Literal>
                                                    </div>
                                                    <div style="width: 100%; padding-left: 25px; padding-top: 25px;">
                                                        <a href="Blog_Photo_Catalog.aspx"><span style="font-size: 12px;"><strong>分类管理</strong></span></a>
                                                    </div>
                                                </div>
                                                <div style="width: 85%; float: right;">
                                                    <div style="padding-top: 20px;">
                                                    </div>
        <asp:DataList ID="DataList1" runat="server" Width="500px" DataKeyField="ID" OnDeleteCommand="DataList1_DeleteCommand" OnItemDataBound="DataList1_ItemDataBound" OnEditCommand="DataList1_EditCommand" OnItemCommand="DataList1_ItemCommand">
            <EditItemTemplate>
               
            </EditItemTemplate>
            <ItemTemplate>
                <table border="0">
                    <tr>
                        <td rowspan="3" style="width: 151px">
                            <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl='<%# Eval("ImgMin") %>'/></td>
                        <td style="width: 172px; height: 34px">
                           
                            <a id='<%# Eval("ID").ToString() %>' name="objb4" onclick="openDiv3(this);" style="cursor:hand; color:Blue;">改</a>
 
                            <!--<a href='Blog_Photo_User_List.aspx?ID=<%# Eval("ID") %>' onclick="openDiv3();"  style="cursor:hand; color:Blue;" runat="server" id="b5"></a>-->
                            &nbsp;
                            <asp:LinkButton ID="txt_delete" runat="server">删</asp:LinkButton>
                            &nbsp;
                           
                            <a id="b1" name="objb1" runat="server" onclick="openDiv();" style="cursor:hand; color:Blue;">移</a>
                            排序:
                            <a id="b2" name="objb2" runat="server" onclick="openDiv1();" style="cursor:hand; color:Blue;">↑</a>&nbsp;
                           
                            <a id="b3" name="objb3" runat="server" onclick="openDiv2();" style="cursor:hand; color:Blue;">↓</a>
                            </td>
                    </tr>
                    <tr>
                        <td style="width: 172px; height: 34px">
                            <asp:LinkButton ID="LinkButton2" runat="server">设为形象照</asp:LinkButton></td>
                    </tr>
                    <tr>
                        <td style="width: 172px; height: 36px">
                            <asp:LinkButton ID="LinkButton1" runat="server" Width="82px" CommandName="Commend"><%# ReturnCommend(Eval("Commend").ToString()) %></asp:LinkButton></td>
                    </tr>
                </table>
            </ItemTemplate>
        </asp:DataList>
           <div id="divBG3"
    style="display:none; position: absolute; left:0px; top:0px; background-color:#C0C0C0;">
    </div>
        <div id="divCtrl3" class="" style="display:none; position: absolute; background-color:Transparent; width:400px; top:0px; left:200px;">
        <table width="100%">
            <tr>
                <td style="height:180px;"></td>
            </tr>
            <tr>
                <td>
                    <table id="tb4" style="background-color:#C6D5F5; width:280px; border-color:#999999" border="0px"; cellpadding="0" cellspacing="1">
                        <tr>
                            <td align="right" ><a onclick="closeDiv3();" style="cursor:hand"><B><font color="red">关闭</font></B> </a></td>
                        </tr>
                        <tr>
                            <td style="background-color:White;"></td>
                        </tr>
                        <tr>
                            <td align="center" style="background-color:White; width:35%">
                            标题:
                                <asp:TextBox ID="txt_FileName" runat="server">
                                </asp:TextBox><br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            简介:
                                <asp:TextBox ID="txt_introduction" runat="server" TextMode="MultiLine"></asp:TextBox>
                                <br />
                                <asp:LinkButton ID="LinkButton9" runat="server">确定</asp:LinkButton>
                                <asp:LinkButton ID="LinkButton10" runat="server">取消</asp:LinkButton>
                                <asp:Label ID="txt_ID" runat="server" Visible="True"></asp:Label>
                                <input type="hidden" runat="server" />
                                </td>
                                </td>
                        </tr>
                        <tr>
                            <td colspan="2" style="background-color:#D4D4D4; height:15px;"></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        </div>
        
        
        <div id="divBG"
    style="display:none; position: absolute; left:0px; top:0px; background-color:#C0C0C0;">
    </div>
        <div id="divCtrl" class="" style="display:none; position: absolute; background-color:Transparent; width:400px; top:0px; left:200px;">
        <table width="100%">
            <tr>
                <td style="height:180px;"></td>
            </tr>
            <tr>
                <td>
                    <table id="tb1" style="background-color:#C6D5F5; width:280px; border-color:#999999" border="0px"; cellpadding="0" cellspacing="1">
                        <tr>
                            <td align="right" ><a onclick="closeDiv();" style="cursor:hand"><B><font color="red">关闭</font></B> </a></td>
                        </tr>
                        <tr>
                            <td style="background-color:White;"></td>
                        </tr>
                        <tr>
                            <td align="center" style="background-color:White; width:35%">
                            转移到分类:
                                <asp:DropDownList ID="ddl" runat="server">
                                </asp:DropDownList><br />
                                <asp:LinkButton ID="LinkButton3" runat="server">确定</asp:LinkButton>
                                <asp:LinkButton ID="LinkButton4" runat="server">取消</asp:LinkButton></td>
                        </tr>
                        <tr>
                            <td colspan="2" style="background-color:#D4D4D4; height:15px;"></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        </div>
        <div id="divBG1"
    style="display:none; position: absolute; left:0px; top:0px; background-color:#C0C0C0;">
    </div>
        <div id="divCtrl1" class="" style="display:none; position: absolute; background-color:Transparent; width:400px; top:0px; left:200px;">
        <table width="100%">
            <tr>
                <td style="height:180px;"></td>
            </tr>
            <tr>
                <td>
                    <table id="tb2" style="background-color:#C6D5F5; width:280px; border-color:#999999" border="0px"; cellpadding="0" cellspacing="1">
                        <tr>
                            <td align="right" ><a onclick="closeDiv1();" style="cursor:hand"><B><font color="red">关闭</font></B> </a></td>
                        </tr>
                        <tr>
                            <td style="background-color:White;"></td>
                        </tr>
                        <tr>
                            <td align="center" style="background-color:White; width:35%">
                            向前跳几位:
                                <asp:TextBox ID="txt_up" runat="server" Text="1">
                                </asp:TextBox><br />
                                <asp:LinkButton ID="LinkButton5" runat="server">确定</asp:LinkButton>
                                <asp:LinkButton ID="LinkButton6" runat="server">取消</asp:LinkButton></td>
                        </tr>
                        <tr>
                            <td colspan="2" style="background-color:#D4D4D4; height:15px;"></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        </div>
           <div id="divBG2"
    style="display:none; position: absolute; left:0px; top:0px; background-color:#C0C0C0;">
    </div>
        <div id="divCtrl2" class="" style="display:none; position: absolute; background-color:Transparent; width:400px; top:0px; left:200px;">
        <table width="100%">
            <tr>
                <td style="height:180px;"></td>
            </tr>
            <tr>
                <td>
                    <table id="tb3" style="background-color:#C6D5F5; width:280px; border-color:#999999" border="0px"; cellpadding="0" cellspacing="1">
                        <tr>
                            <td align="right" ><a onclick="closeDiv2();" style="cursor:hand"><B><font color="red">关闭</font></B> </a></td>
                        </tr>
                        <tr>
                            <td style="background-color:White;"></td>
                        </tr>
                        <tr>
                            <td align="center" style="background-color:White; width:35%">
                            向后跳几位:
                                <asp:TextBox ID="txt_down" runat="server" Text="1">
                                </asp:TextBox><br />
                                <asp:LinkButton ID="LinkButton7" runat="server" OnClick="LinkButton7_Click">确定</asp:LinkButton>
                                <asp:LinkButton ID="LinkButton8" runat="server">取消</asp:LinkButton></td>
                        </tr>
                        <tr>
                            <td colspan="2" style="background-color:#D4D4D4; height:15px;"></td>
                        </tr>
                    </table>
                </td>
            </tr>
        </table>
        </div>
        
        <br />
        <webdiyer:AspNetPager ID="AspNetPager1" PageSize="20" runat="server" OnPageChanging="AspNetPager1_PageChanging">
                                    </webdiyer:AspNetPager>
    </div>
    </asp:View>
    </asp:MultiView>
    </td>
    </tr>
    </table>
    </div>
      
    </form>
</body>
</html>


这是全部的页面代码

2008-09-26 14:44
191638141
Rank: 1
等 级:新手上路
帖 子:112
专家分:0
注 册:2008-1-5
收藏
得分:0 
首先定义一个隐藏控件 用JS写入其中
然后后台用request["id"]来获取;
2008-09-26 15:00
lmyh5201
Rank: 1
等 级:新手上路
帖 子:241
专家分:0
注 册:2007-3-29
收藏
得分:0 
<input type="hidden" runat="server" id="txt_ID"/>这是定义了一个隐藏控件,后面怎么做啊

2008-09-26 15:01
lmyh5201
Rank: 1
等 级:新手上路
帖 子:241
专家分:0
注 册:2007-3-29
收藏
得分:0 
怎么用JS写入其中阿

2008-09-26 15:04
kevintang
Rank: 4
等 级:业余侠客
威 望:9
帖 子:799
专家分:236
注 册:2008-2-14
收藏
得分:0 
function openDiv3(id)
    {
document.getElementById('txt_ID').value = id.id;
        var txt_ID=id.id;
        sWidth=document.body.offsetWidth;
        sHeight=screen.height;
        
        var bgObj=document.getElementById('divBG3');
        bgObj.style.filter="progid:DXImageTransform.Microsoft.Alpha(style=2,opacity=25,finishOpacity=75";
        bgObj.style.opacity="0.5";
        bgObj.style.width = sWidth;
        bgObj.style.height = sHeight;
        bgObj.style.display="inline";
        
        var bgObjCtrl = document.getElementById('divCtrl3');
        bgObjCtrl.style.width = sWidth;
        bgObjCtrl.style.display="inline";
        document.all("objb4").disabled=true;
        
    }

编程少年基地——少年编程者的练兵场
http://bcsn.    招聘版主中

2008-09-26 15:07
andyhuang66cn
Rank: 1
等 级:新手上路
帖 子:35
专家分:0
注 册:2008-9-6
收藏
得分:0 
楼上正解,从中受益!

机会是创造出来的
2008-10-13 16:18
love329125
Rank: 1
来 自:湖北
等 级:新手上路
帖 子:67
专家分:0
注 册:2008-1-5
收藏
得分:0 
确实是高手
真的

开心!!
2008-10-16 14:39
快速回复:.net后台的函数怎么调用JS里的变量值啊?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.039396 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved