在内容页面中使用VirtualKeyboard

时间:2014-01-09 05:03:32

标签: asp.net master-pages virtual-keyboard

我创建了一个使用VirtualKeyboard的母版页。它工作正常,但是当我在内容页面中使用它时它不起作用。

这是主页中的代码:

    <head runat="server">
        <title></title>
          <link href="css/keyboard.css" rel="stylesheet" />
                <link rel="stylesheet" href="css/demo.css" />
                <script src="script/prototype.js"></script>
                <script src="script/keyboard.js"></script>
        <asp:ContentPlaceHolder ID="head" runat="server">
        </asp:ContentPlaceHolder>
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
                <cc1:VirtualKeyboard ID="VirtualKeyboard1" runat="server" ClientIDMode="AutoID" CssClass="KeyBoard" ForControl="TextBox1" />
            </div>
            <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">

            </asp:ContentPlaceHolder>
        </form>
    </body>

这是内容页面中的代码:

<%@ Page Title="" Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<%@ Register Assembly="SPCS.AspDotNet" Namespace="SPCS.AspDotNet" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <cc1:VirtualKeyboard ID="VirtualKeyboard1" runat="server" ForControl="TextBox1" />
</asp:Content>

1 个答案:

答案 0 :(得分:0)

请在TextBox中设置ClientIDMode =“Static”,因为默认情况下它是Inherit所以它可能会生成AutoID并尝试

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:TextBox ID="TextBox1" runat="server" ClientIDMode="Static"></asp:TextBox>
    <cc1:VirtualKeyboard ID="VirtualKeyboard1" runat="server" ForControl="TextBox1" />
</asp:Content>