惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

S
Secure Thoughts
罗磊的独立博客
T
The Blog of Author Tim Ferriss
人人都是产品经理
人人都是产品经理
博客园 - 叶小钗
Last Week in AI
Last Week in AI
美团技术团队
Google Online Security Blog
Google Online Security Blog
Application and Cybersecurity Blog
Application and Cybersecurity Blog
D
Docker
G
Google Developers Blog
大猫的无限游戏
大猫的无限游戏
酷 壳 – CoolShell
酷 壳 – CoolShell
小众软件
小众软件
月光博客
月光博客
L
LINUX DO - 最新话题
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
W
WeLiveSecurity
H
Heimdal Security Blog
Vercel News
Vercel News
SecWiki News
SecWiki News
Forbes - Security
Forbes - Security
Blog — PlanetScale
Blog — PlanetScale
Google DeepMind News
Google DeepMind News
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
TaoSecurity Blog
TaoSecurity Blog
T
Troy Hunt's Blog
A
About on SuperTechFans
C
Check Point Blog
S
Security Affairs
Hacker News - Newest:
Hacker News - Newest: "LLM"
AI
AI
WordPress大学
WordPress大学
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
Help Net Security
Help Net Security
博客园_首页
The Last Watchdog
The Last Watchdog
S
SegmentFault 最新的问题
Hugging Face - Blog
Hugging Face - Blog
Security Archives - TechRepublic
Security Archives - TechRepublic
Engineering at Meta
Engineering at Meta
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
I
Intezer
K
Kaspersky official blog
M
MIT News - Artificial intelligence
J
Java Code Geeks
G
GRAHAM CLULEY
P
Palo Alto Networks Blog

博客园 - RevengeBoy

请求帮助 SQL 2005 master..xp_cmdshell 死锁问题 Rc4 encrypt in PeopleSoft - RevengeBoy CSS隐藏滚动条 - RevengeBoy - 博客园 程序员 2008的最后一天 大家有什么感想说出来吧 vista ie7 window.confirm() 取消按钮 失效 解决办法 - RevengeBoy 魔兽争霸III 1.20, 1.21 1.22 需要特定语言版本之Window 解决办法 css 换行 且不分割最后一个单词 - RevengeBoy 英文系统 中 中文成了乱码问题 sql 查询第5行到第7行 之间的行 反射技术与工厂方法 (using C#) 图片水印效果 - RevengeBoy - 博客园 Membership、MembershipUser和Roles类 上传大文件控件 显示进度条! [转]ASP.NET(C#)常用代码33例 电脑常识---[二] 最近创作---用户控件 蓦然回首 profile 的使用(更换皮肤转换语言) dropdownlist 下的 SelectedValue 问题
(OnClientClick 和 OnClick 新页面回传值)(gridview中获取控件 获取值)
RevengeBoy · 2007-07-27 · via 博客园 - RevengeBoy

曾经遇到这么一个问题 
在一个弹出的窗口中
我的一个 button 要执行两个事件
一 、
    protected void Button1_Click(object sender, EventArgs e)
    {
string revengeboy="";
revengeboy = "我是杀手马大哈一天到晚杀杀杀";//这个只是做例子随便写了个
    }
二、
之后还得执行这个事件
<script language="javascript" type="text/javascript">
// <!CDATA[

  function InputButton1_onclick()
  {
        window.dialogArguments.aspnetForm.InputRoles.value = '<%= revengeboy%>';//把值回传
        window.close(); //关闭窗口
   }
// ]]>
</script>

郁闷的是OnClientClick  是比 OnClick先执行的 要想达到 先附值在 执行脚本中的方法OnClientClick ="InputButton1_onclick()"  OnClick=Button1_Click 这是完全达不到所要的效果的
而且我自做聪明的以为
    protected void Button1_Click(object sender, EventArgs e)
    {
        GetSelectedRoles();
        this.Button1.Attributes.Add("OnClick", "javascript:InputButton1_onclick()");
    }
这样可以达到效果  ,但我错了错的不算很离谱,怎么说呢 因为这个按扭要点两下才可以达到效果;

最终方法:
无奈经历了这么几个错误 ,我想只有把他写到后台页面或许可以...
    protected void Button1_Click(object sender, EventArgs e)
    {
        GetSelectedRoles();
        Response.Write("<script>window.dialogArguments.aspnetForm.InputRoles.value ='"+revengeboy+"';window.close();</script>");  
    } 恩 这个达到了我要的效果 哈哈!!!

    private void  GetSelectedRoles()//从gridview中找到控件并获取值
    {
        foreach (GridViewRow row in GridView1.Rows)
        {

            //this.Lable3.Text +=  + (row.FindControl("Label2") as Label).Text;
            //itemname = itemname + ((Label)GridView1.Rows[row.RowIndex].FindControl("Label2")).Text;//.Cells[4].Controls[0]).Text.Trim();
            roles = ((Label)GridView1.Rows[row.RowIndex].Cells[1].FindControl("TxtRoleName")).Text.ToString();
            CheckBox cb1 = (CheckBox)GridView1.Rows[row.RowIndex].FindControl("CheckBox4");
            CheckBox cb2 = (CheckBox)GridView1.Rows[row.RowIndex].FindControl("CheckBox5");
            CheckBox cb3 = (CheckBox)GridView1.Rows[row.RowIndex].FindControl("CheckBox6");
            if (cb1.Checked == true || cb2.Checked == true || cb3.Checked == true)
            {
                if (cb1.Checked == true)
                {
                    read = "R-Y";
                }
                else
                {
                    read = "R-N";
                }
                if (cb2.Checked == true)
                {
                    write = "W-Y";
                }
                else
                {
                    write = "W-N";
                }
                if (cb3.Checked == true)
                {
                    update = "U-Y";
                }
                else
                {
                    update = "U-N";
                }
                itemname = itemname +  roles + "," + read + "," + write + "," + update+"|" ;
            }
           
        }
        this.Label3.Text = itemname.ToString();
    }