子页中的代码<td class="content_blue12" align="right" style="height: 8px; width:13%">テスト時間:&nbsp; </td>
            <td style="height: 8px; width:34%">
                <asp:TextBox ID="TextBox1" runat="server"> </asp:TextBox>&nbsp; </td>
            <td class="content_blue12" align="right" style="height: 8px; width:13%">試験科目:&nbsp; </td>
            <td style="height: 8px; width:25%">
                &nbsp; <asp:DropDownList ID="DropDownList1" runat="server" Height="23px" Width="171px">
                </asp:DropDownList> </td>
            <td align="right" style="height: 8px; width:15%">
                <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="検索" Width="80px" /> </td>
母版也中的代码
<td class="content_blue12" align="right" style="height: 8px; width:13%">テスト時間:&nbsp; </td>
            <td style="height: 8px; width:34%">
                <input name="ctl00$ContentPlaceHolder1$TextBox1" type="text" id="ctl00_ContentPlaceHolder1_TextBox1" onfocus="show_cele_date(ctl00$ContentPlaceHolder1$TextBox1,'','',ctl00$ContentPlaceHolder1$TextBox1)" />&nbsp; </td>
            <td class="content_blue12" align="right" style="height: 8px; width:13%">試験科目:&nbsp; </td>
            <td style="height: 8px; width:25%">
                &nbsp; <select name="ctl00$ContentPlaceHolder1$DropDownList1" id="ctl00_ContentPlaceHolder1_DropDownList1" style="height:23px;width:171px;"></select> </td>
            <td align="right" style="height: 8px; width:15%">
                <input type="submit" name="ctl00$ContentPlaceHolder1$Button1" value="検索" id="ctl00_ContentPlaceHolder1_Button1" style="width:80px;" /> </td>

解决方案 »

  1.   


        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack != false)
            {
                return;
            }        this.TextBox1.Attributes.Add("onfocus", "show_cele_date(document.getElementById('<%=TextBox1.ClientID%>')),'','',document.getElementById('<%=TextBox1.ClientID%>')");        
        }
    我在里面这样写,好像还是不对。show_cele_date这个事js文件里面的一个方法。
    错误是
     public static WebInvokeContext CreateWebInvokeContext(HttpApplication context)
            {
                WebInvokeContext wIContext = new WebInvokeContext();
                wIContext.application = context.Application;
                wIContext.context = context.Context;
                wIContext.request = context.Request;
                wIContext.response = context.Response;
                wIContext.server = context.Server;
                wIContext.session = context.Session;    このコンテキストでセッション状態は利用できません。
                return wIContext;
            }
    意思是说这个通过context ,session状态不能利用
      

  2.   

    出现上面的错误,是因为我引用js文件会报出上面错误,我现在时把js文件添加到母版页中但是 还是还是出现传递参数会出错
    this.TextBox1.Attributes.Add("onfocus", "show_cele_date(TextBox1.ClientID,'','',TextBox1.ClientID)");
    这样传递参数也是错误的按照上面的写法 也是错误的
    this.TextBox1.Attributes.Add("onfocus", "show_cele_date(document.getElementById(' <%=TextBox1.ClientID%>')),'','',document.getElementById(' <%=TextBox1.ClientID%>')");