Return Value code in the JS pop-up dialog box (asp.net background)

Source: Internet
Author: User

1. Default. aspx page Copy codeThe Code is as follows: <script type = "text/javascript">
Function GetUser (TxtEmpID, TxtEmpName, url)
{
Var properties = 'status: no; resizable: no; toolbar = no; menubar = no; location = no; scroll: no; dialogWidth: 540px; dialogHeight: 450px ;'
Var arg = window. showModalDialog (url, "", properties );
If (arg! = Null)
{
Document. getElementById (TxtEmpID). value = arg [0];
Document. getElementById (TxtEmpName). value = arg [1];
}
}
</Script>
<Table width = "240px" cellpadding = "0" cellspacing = "0">
<Tr>
<Td style = "width: 80px">
<Asp: label ID = "Label1" runat = "server" Text = "" Width = "80px" class = "font-w"> </asp: label> </td>
<Td style = "width: 80px">
<Asp: TextBox ID = "TextBox1" runat = "server" ReadOnly = "false" Width = "80px" onfocus = "this. blur ()"> </asp: TextBox>
</Td>
<Td style = "width: 80px">
<Asp: TextBox ID = "TextBox2" runat = "server" ReadOnly = "false" Width = "80px"> </asp: TextBox>
</Td>
<Td style = "width: 80px">
<Asp: Button ID = "Button1" runat = "server" Text = "Confirm" OnClick = "button#click" CssClass = "ButtonCss"/>
</Td>
<Td>
<Asp: Label ID = "Label3" runat = "server" Text = ""> </asp: Label> </td>
<Td> <asp: Label ID = "Label4" runat = "server" Text = ""> </asp: Label> </td>
</Tr>
</Table>

2. Default. aspx. csCopy codeThe Code is as follows: protected void Page_Load (object sender, EventArgs e)
{
TextBox1.Attributes. Add ("onclick", "GetUser ('" + this. TextBox1.ClientID + "', '" + this. TextBox2.ClientID + "', 'webdialog. aspx )");
}

3. WebDialog. aspxCopy codeThe Code is as follows: <script language = "javascript" type = "text/javascript">
Function Submit ()
{
Var arr = new Array ();
Arr [0] = document. getElementById ('txtempid'). value
Arr [1] = document. getElementById ('txtempcname'). value
Arr [2] = document. getElementById ('txttitleid'). value

Window. returnValue = arr;
Window. close ();
}

</Script>
<Table>
<Tr> <td>
<Asp: TextBox ID = "TxtEmpID" runat = "server" Width = "50px" ReadOnly = "true" CssClass = "InputCss"> </asp: TextBox>
<Asp: TextBox ID = "TxtEmpCName" runat = "server" Width = "60px" ReadOnly = "true" CssClass = "InputCss"> </asp: TextBox>
<Asp: TextBox ID = "TxtTitleID" runat = "server" Width = "40px" ReadOnly = "true" CssClass = "InputCss"> </asp: TextBox>
</Tr> </td>
<Tr> <td>
<Input id = "Button1" type = "button" value = "Confirm" onclick = "Submit ()"/>
</Tr> </td>
</Table>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.