请教高手....如何在FormView的Edit模板和Insert模板中实现,TextBox双击弹出一个窗体.然后双击窗体的值返回到FormView的TextBox中.最主要我不清楚,如何在模板中添加脚本.... 如果放在页面的title中.根本就调用不了.谢谢了.

解决方案 »

  1.   

    <head runat="server">
        <title>无标题页</title>
        <script language="javascript" type="text/javascript">
        function showWin(objTxt)
        {
            var newWin = window.showModalDialog("smallWin.aspx");
            
            if(newWin != null)
            {
                       objTxt.value = newWin;
            }
        }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:FormView ID="FormView1" runat="server" AllowPaging="True" DataKeyNames="CityID"
                DataSourceID="AccessDataSource1" DefaultMode="Edit" OnItemCreated="FormView1_ItemCreated" OnDataBound="FormView1_DataBound">
                <EditItemTemplate>
                    CityID:
                    <asp:Label ID="CityIDLabel1" runat="server" Text='<%# Eval("CityID") %>'></asp:Label><br />
                    City:
                    <asp:TextBox ID="CityTextBox" runat="server" Text='<%# Bind("City") %>' ondblclick="showWin(this);">
                    </asp:TextBox>....
      

  2.   

    <%@ Page Language="C#" AutoEventWireup="true" CodeFile="smallWin.aspx.cs" Inherits="smallWin" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
    <head runat="server">
        <title>无标题页</title>
        <base target="_self" />
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
        </form>
    </body>
    </html>
    ================================
    protected void Button1_Click(object sender, EventArgs e)
        {
            string tmp = DateTime.Now.ToString();//需要回传到父页面的值
            Page.ClientScript.RegisterStartupScript(typeof(string), "close", "<script>this.returnValue='"+tmp+"';window.close();</script>");
        }