PDA

View Full Version : سوال: عدم اجرای کد در ویژوال استودیو 2015



majid.sh
دوشنبه 20 دی 1395, 13:17 عصر
سلام
قطعه کد زیر که مقدار یک کنترل html (TextBox1) را در سمت سرویس گیرنده به یک کنترل ( "TextBox2 runat="server) منتقل می کند در ویژوال استودیو 2010 کار می کند ولی در نسخه 2015 پیغام خطا می دهد که این object شناسایی نشد(TextBox1)
از دوستانی که علت را می دانند خواهشمند است راهنمایی فرمایند.



<script type="text/javascript">
function showTxBValue()
{
var obj = document.getElementById('TextBox1');
if(obj!=null)
{
document.getElementById('<%= TextBox2.ClientID %>').value = document.getElementById('TextBox1').value;
}
else
{
alert("پیدا نشد");
}
}

</script>
</head>
<body>

<form id="form1" runat="server">
<div class="style1" dir="rtl">
<td>
<input name="TextBox1" value="1395/10/19">
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server" ></asp:TextBox>
<input type="button" value="نمایش " onclick="showTxBValue()" />
</td>
</div>
</form>

</body>

mortezagt
سه شنبه 21 دی 1395, 00:12 صبح
<script type="text/javascript">
function showTxBValue()
{
var obj = document.getElementById('TextBox1');
if(obj!=null)
{
document.getElementById('TextBox2').value = document.getElementById('TextBox1').value;
}
else
{
alert("پیدا نشد");
}
}

</script>


<form id="form1" runat="server">
<div class="style1" dir="rtl">
<td>
<input id="TextBox1" value="1395/10/19">
</td>
<td>
<asp:TextBox ID="TextBox2" runat="server" ></asp:TextBox>
<input type="button" value="نمایش " onclick="showTxBValue()" />
</td>
</div>
</form>