获取Id的价值不是从一个对话框按钮事件显示在直放站 [英] Get value of Id not displayed in the Repeater from a button event of a dialog

查看:105
本文介绍了获取Id的价值不是从一个对话框按钮事件显示在直放站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,试图让已在点击一个asp.net的中继器ID项的值。我直放站有打开一个对话框的图像,并从该对话框中打开,当我点击批准,我想在cs文件获取此值时,我重定向因为ApproveChange_Click事件。我没有做任何的DataBinder.Eval我想要在直放站检索标识。我怎样才能做到呢?如果我使用会话变量,在那里我可以设置在.aspx页以及如何价值。在此先感谢!

这是直放站:

 < TR类=<%#Container.ItemIndex%2 = 0!?:奇%GT;>
     < TD类=审批-IMG><一类=approvalDialog的href ='#'>< IMG SRC =/图像/ Approve.pngALT =批准/>< / TD>&下; / A>
     < TD类=审批-IMG><一类=declineDialog的href ='#'>< IMG SRC =/图像/ Decline.pngALT =拒绝/>< / TD>&下; / A>
     ...
< / TR>

和这个对话框:

 < D​​IV ID =审批型的风格=显示:无;光标:默认的>
    < D​​IV CLASS =批准变更>
        < UL>
        <立GT;
            < P><标签>原因及LT; /标签>< / P>
            < textarea的ID =txtReason=服务器COLS =1行=1级=必需>< / textarea的>< BR />
        < /李>
        <立GT;
            <跨度>
            < ASP:按钮的ID =btnApprove=服务器的CssClass =蓝色文本=批准工具提示=批准的OnClick =ApproveChange_Click/>
            <按钮ID =btnCancelApprove级=蓝>取消< /按钮>
            < / SPAN>
        < /李>
        < / UL>
    < / DIV>
< / DIV>


解决方案

下面是我找到了解决办法:
第一:在中继器的ImageButton改变标记,必须发送一个命令参数事件的几率

 < TD类=审批-IMG>< ASP:ImageButton的=服务器CommandArgument ='<%#的eval(aux_approvalId)%> 的OnClick =getApprovalID_approve工具提示=批准的ImageUrl =/图像/ Approve.png/>< / TD>

所以,当我重定向到OnClick事件,有了这个,我得到的ID,并打开对话框后。

 的ImageButton BTN =(的ImageButton)(寄件人);
会话[ApprovalID] = btn.CommandArgument;
字符串脚本=OpenApprovalDialog();;
Page.ClientScript.RegisterStartupScript(typeof运算(页),,剧本,真);

I'm having a problem trying to get the value of the ID item that has been clicked in an asp.net Repeater. My Repeater has an image that opens a dialog, and from that dialog opened, when I click Approve, I would like to get this value in the .cs file when I'm redirected because the ApproveChange_Click event. I'm not doing any DataBinder.Eval to the Id I want to retrieve in the Repeater. How can I accomplish that? If I use session variables, where I can set up the value in the .aspx page and how. Thanks in advance!

This is the Repeater:

<tr class="<%# Container.ItemIndex % 2 != 0 ? "" : "odd" %>">
     <td class ="approval-img"><a class ="approvalDialog" href='#'><img src="/Images/Approve.png" alt ="Approve"/></td></a>
     <td class ="approval-img"><a class ="declineDialog" href='#'><img src="/Images/Decline.png" alt ="Decline"/></td></a>
     ...
</tr>

And this the dialog:

<div id="approval-form" style="display: none; cursor: default">
    <div class="approve-change">
        <ul>
        <li>
            <p><label>Reason</label></p>
            <textarea id="txtReason" runat="server" cols="1" rows="1" class="required"></textarea><br />
        </li>
        <li>
            <span>
            <asp:Button ID="btnApprove" runat="server" CssClass="blue" Text="Approve" ToolTip = "Approve" OnClick="ApproveChange_Click" />
            <button id="btnCancelApprove" class="blue">Cancel</button>
            </span>
        </li>
        </ul>
    </div>
</div>

解决方案

Here is the solution that I have found: First: change the tag in the repeater for ImageButton, for have the chance to send a command argument to the event

<td class ="approval-img"><asp:ImageButton runat="server" CommandArgument = '<%# Eval("aux_approvalId")%>'  OnClick="getApprovalID_approve" ToolTip="Approve" ImageUrl="/Images/Approve.png" /></td>

So, when I'm redirected to OnClick event, with this, I get the ID and after the dialog is opened.

ImageButton btn = (ImageButton)(sender);
Session["ApprovalID"] = btn.CommandArgument;
string script = "OpenApprovalDialog();";
Page.ClientScript.RegisterStartupScript(typeof(Page), "", script, true);

这篇关于获取Id的价值不是从一个对话框按钮事件显示在直放站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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