私は2つのWebフォームを使用し、1つのWebフォームを使用し、これから2番目のWebフォームでダイアログを開きたいと考えています。ListView から LinkButton をクリックするとダイアログが開き、正常に動作しますが、2 番目の Web フォームの値が必要なため、最初にダイアログを開きます。このダイアログは空です。このダイアログを閉じると、値がセッションに送信されます。
ASPX:
...
<script type="text/javascript">
function OpenChild() {
var WinSettings = "center:yes;resizable:no;dialogHeight:550px"
var MyArgs = window.showModalDialog("Benutzer.aspx", MyArgs, WinSettings);
}
</script>
...
<asp:ListView runat="server" ID="myListView">
<LayoutTemplate>
<table id="UserTable" runat="server" border="0" width="800" cellpadding="0" cellspacing="0">
<tr style="background-color:#E5E5FE" class="TableClass">
<th id="th1" runat="server"><asp:LinkButton ID="lnkBenutzer" runat="server" >id_Benutzer</asp:LinkButton></th>
<th id="th2" runat="server"><asp:LinkButton ID="lnkemail" runat="server" >id_Email</asp:LinkButton></th>
<th id="th3" runat="server"><asp:LinkButton ID="lnkVorname" runat="server" >id_Vorname</asp:LinkButton></th>
<th id="th4" runat="server"><asp:LinkButton ID="lnkNachname" runat="server" >id_Nachname</asp:LinkButton></th>
<th id="th5" runat="server"><asp:LinkButton ID="lnkTelefon" runat="server" >id_Telefon</asp:LinkButton></th>
</tr>
<tr runat="server" id="ItemPlaceholder">
</tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr class="TableClass">
<td align="left" ><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label1" Text='<%# Eval("Benutzername") %>' runat="server" OnClientClick="OpenChild()" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label2" Text='<%# Eval("eMail") %>' runat="server" OnClientClick="OpenChild()" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label3" Text='<%# Eval("Vorname") %>' runat="server" OnClientClick="OpenChild()" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label4" Text='<%# Eval("Nachname") %>' runat="server" OnClientClick="OpenChild()" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label5" Text='<%# Eval("Telefonnummer") %>' runat="server" OnClientClick="OpenChild()" /></td>
<td align="left"><asp:Label ID="Label6" Text='<%# Eval("GUID") %>' runat="server" Visible="False" /></td>
</tr>
</ItemTemplate>
<AlternatingItemTemplate>
<tr class="TableClass">
<td align="left" ><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label1" Text='<%# Eval("Benutzername") %>' runat="server" OnClientClick="OpenChild()" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label2" Text='<%# Eval("eMail") %>' runat="server" OnClientClick="OpenChild()" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label3" Text='<%# Eval("Vorname") %>' runat="server" OnClientClick="OpenChild()" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label4" Text='<%# Eval("Nachname") %>' runat="server" OnClientClick="OpenChild()" /></td>
<td align="left"><asp:LinkButton CssClass="MyLink" OnCommand="Button1_Command" CommandName="Select" CommandArgument='<%# Container.DataItemIndex %>' ID="Label5" Text='<%# Eval("Telefonnummer") %>' runat="server" OnClientClick="OpenChild()" /></td>
<td align="left"><asp:Label ID="Label6" Text='<%# Eval("GUID") %>' runat="server" Visible="False" /></td>
</tr>
</AlternatingItemTemplate>
</asp:ListView>
C# コード:
...
protected void Button1_Command(object sender, CommandEventArgs e)
{
if (e.CommandName == "Select")
{
//Der Index der Zeile wird ermitellt
int index = Convert.ToInt32(e.CommandArgument);
//Der Inhalt (GUID[Unsichtbar]) wird aus der zeile mit dem Index herausgezogen und übergeben
Label lb = (Label)myListView.Items[index].FindControl("Label6");
//Der GUID, Benutzer-Nachname und das Werk werden an eine Session übergeben
Session["UserID"] = lb.Text;
Session["SearchUser"] = txtBenutzer.Text;
Session["DropDownValue"] = dropWerk.SelectedValue;
//Es wird eine neue Webform geöffnet
Response.Redirect("Benutzer.aspx",true);
}
}
...
値をセッションに保存し、ダイアログを開くよりも
タラソフ