在asp.net中具有母版页的textchanged属性中的问题 [英] Problem in textchanged property in asp.net with master page

查看:85
本文介绍了在asp.net中具有母版页的textchanged属性中的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是当我在第一个文本框中键入内容时,我想在另一个文本框中相应地显示文本框中的文本长度.我的如下所示的代码对于没有母版页的页面正常运行,但是我想在附在母版页(forum.master)上的页面(ask.aspx)中执行此操作.我的没有mster的页面的代码是

my problem is that i want to display length of the text of textbox in another textbox correspondingly as i type in first textbox. my code as shown below is working properly for a page without masterpage, but i want to do this in a page(ask.aspx) which is attaced to a masterpage(forum.master). my code that is working for a page without mster is

<<pre lang="xml">%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="ADVANCED_FORUM.test" %>

<!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>Untitled Page</title>
    <script type="text/javascript">
function showtextlen()
{
var objcount=document.getElementById("ta2");
var objsub=document.getElementById("ta1");
if(objcount  && objsub)
{
objcount.innerText=objsub.value.length;
}
else
{
objcount.innerText="11";
}
}
</script>
</head>
<body onload="showtextlen();">
    <form id="form1" runat="server">
    <div>
        <textarea id="ta1" runat="server" onkeyup="showtextlen();" cols="20" rows="2" style="z-index: 101; left: 10px; position: absolute; top: 70px"></textarea>
        <textarea id="ta2" runat="server" cols="20" rows="2" style="z-index: 100; left: 196px; position: absolute; top: 70px"></textarea></div>
    </form>
</body>
</html>
</pre>


这工作正常.
现在我的母版页代码是


this is working properly.
Now my master page code is

<<pre lang="xml">%@ Master Language="C#" AutoEventWireup="true" CodeBehind="forum.master.cs" Inherits="ADVANCED_FORUM.forum" %>

<!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">
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>untitled</title>
<meta name="keywords" content="" />
<meta name="description" content="" />
<link href="default.css" rel="stylesheet" type="text/css" />
</head>
<body>
<div id="header" style="height: 273px">
    <div id="logo" style="width: 137px; height: 55px">
        <h1><a href="#">Forums</a></h1>
        <h2><a href="http://www.csstemplatesforfree.com/">By Yogesh Sharma</a></h2>
    </div>
    <div id="menu" style="height: 118px">
        <ul>
            <li class="active"><a href="#" title="">Homepage</a></li>
            <li><a href="#" title="">About Us</a></li>
            <li><a href="main.aspx" title="">View all questions</a></li>
            <li><a href="test.aspx" title="">Unanswered question</a></li>
            <li><a href="ask.aspx" title="">Ask a question</a></li>
        </ul>
    </div>
     <form id="formm" runat ="server" >
       <asp:ContentPlaceHolder ID ="cp1" runat="server">
           <asp:TextBox ID="TextBox1" runat="server" Style="z-index: 100; left: 1px; position: absolute;
               top: 167px"></asp:TextBox>
   </asp:ContentPlaceHolder>
   </form>
</div>
   </body>
</html>



并且我对具有母版页的页面(ask.aspx)的代码是:



AND my code for a page(ask.aspx) having a masterpage is:

<%@ Page Language="C#" AutoEventWireup="true" MasterPageFile="~/forum.Master" CodeBehind="ask.aspx.cs" Inherits="ADVANCED_FORUM.ask" %>
<asp:Content ID="content3" runat="server" ContentPlaceHolderID="cp1">
<asp:Panel ID="Panel1" runat="server" Style="z-index: 104; left: 4px; position: absolute;
        top: 170px" Height="700px" Width="729px" BackColor="#C0C0FF">
     
        <asp:Button ID="btnpostqst" runat="server" Font-Bold="True" ForeColor="#400040" Height="29px"

            OnClick="btnpostqst_Click" Style="z-index: 100; left: 0px; position: absolute;
            top: 665px" TabIndex="4" Text="Post your question" Width="139px" Font-Italic="True" Font-Underline="True" />
        <asp:TextBox ID="txtquestion" runat="server" BorderColor="#400000" BorderStyle="Ridge"

            Height="503px" Style="z-index: 101; left: 7px; position: absolute; top: 144px"

            TabIndex="3" TextMode="MultiLine" Width="708px" EnableViewState="False" AutoCompleteType="Disabled" >
    <asp:Label ID="Label1" runat="server" Font-Bold="True" Font-Italic="True" Font-Underline="True"

        ForeColor="#000040" Style="z-index: 102; left: 2px; position: absolute; top: 33px"

        Text="Subject :">
    <asp:TextBox ID="txtsubject" runat="server" Style="z-index: 103;
        left: 67px; position: absolute; top: 30px" Width="599px" Height="24px" TabIndex="1" OnTextChanged="txtsubject_TextChanged" AutoCompleteType="Disabled">
    <asp:Label ID="Label2" runat="server" Font-Bold="True" Font-Italic="True" Font-Underline="True"

        ForeColor="#000040" Style="z-index: 104; left: 9px; position: absolute; top: 81px"

        Text="Tag :">
     
    <asp:Label ID="Label3" runat="server" Font-Bold="True" Font-Italic="True" Font-Underline="False"

        ForeColor="#000040" Style="z-index: 105; left: 12px; position: absolute; top: 120px"

        Text="Descriptions">
    <asp:TextBox ID="txtcount" runat="server" Height="23px" Style="z-index: 106; left: 685px;
        position: absolute; top: 31px" Width="31px" Enabled="False">
    <asp:DropDownList ID="ddtag" runat="server" Style="z-index: 107; left: 70px; position: absolute;
        top: 79px" Width="354px" EnableViewState="False" TabIndex="2" Height="32px">
    
     


在这里,我想知道应该在哪里定义我的javascript函数,在哪里使用此函数,请通过示例详细说明..这对我来说是个大问题..


here i want to know that where is should define my javascript function and where to use this function please tell in details with example.. its a big problem for me..

推荐答案

这里是一个简单的示例:使用Javascript计算Textarea字符 [ ^ ].

有很多可用的资源(仅适用于Google!),或者如果您在实施方面遇到困难,请继续提出另一个问题,并提供更多详细信息.

干杯.
Here''s a simple example: Count Textarea Characters With Javascript[^].

There''s lots of resources available for this (just Google!), or if you have trouble with implementation, go ahead and post another question with more specifics.

Cheers.


这篇关于在asp.net中具有母版页的textchanged属性中的问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆