gpt4 book ai didi

vb.net - 如何将消失标签编程到 ASP 文本框中?

转载 作者:行者123 更新时间:2023-12-02 10:02:39 26 4
gpt4 key购买 nike

我正在开发一个VB.NET程序。我目前有一个 ASP 文本框,里面显示一个标签。但现在客户必须在输入自己的文本之前手动删除此标签。如何让这个标签在他们开始打字后立即消失?

我的脚本现在几乎可以用于 txtFind 了。但在这种情况下,它显示一个不同的文本框来显示水印图像。如何重置此水印以仅激活 txtFind 文本框?并删除左侧的文本框?这是我的新 ASPX 文件代码:

    <script type="text/javascript" language="javascript" >
function GetChart(thepart, thepartdesc, thecolor, row)
{
Form1.part_transfer.value = thepart;
Form1.part_desc_transfer.value = thepartdesc;
Form1.submit();
}
</script>

<head>
<title></title>
<style type="text/css">
.DataGridFixedHeader {background-color: #336699; color:White; font-weight: "bold"; position:relative; top:expression(this.offsetParent.scrollTop);}
#txtWatermark{ width:150; padding:5px; outline:none; height:20px; }
.focusField{ border:solid 2px #73A6FF; background:#EFF5FF; color:#000; }
.idleField{ background:#EEE; color: #6F6F6F; border: solid 2px #DFDFDF; }
</style>
</head>
<body>
<form runat="Server" defaultbutton= "btnFind" method="post" id="Form1">
<div style="font-size:18pt; font-family:verdana; font-weight:bold; color:#336699">
Parts Watch List
</div>
<hr style="font-weight: bold; font-size: 20pt; color:#000080;" />
<div style="height: 380px; text-align: center; position: static;">
<input id="part_transfer" type="hidden" runat="server"/>
<input id="part_desc_transfer" type="hidden" runat="server"/>
<asp:Panel id="Panel1" runat="server" HorizontalAlign = "Center">
<span style="font-weight: bold; text-align: left; font-size: 15pt;">
Calculation:</span><br />
Reliability Rate &nbsp;=&nbsp; 1 - ( number of failed parts in the last 6 months / Part Multiplier * Average instrument Census in the last 6 months),<br />
Where
<br />
Number of failed parts - Summation of failures of a part for a 6 month period<br />
Part Multiplier - Number that represents how many times a part is used on the intrument<br />
Average instrument census -&nbsp; Average of the instrument census for the same
6 month timeframe as failed parts<br />
<br />
&nbsp; &nbsp; &nbsp;
Please choose one of the parts below to view the control charts.</p>
</asp:Panel>
<asp:Panel id="Panel2" runat="server" Visible="false">
<chart:WebChartViewer id="WebChartViewer1" runat="server" HorizontalAlign="Center" />
</asp:Panel>
</div>
<hr style="width: 90%; position: static;" />

<div style="text-align: center; position: static; ">
<asp:Label id="CensusLastUpdate" runat="server"/><br />
<asp:Button id="btnExport" runat="server" Text="Export to Excel"></asp:Button>
<asp:CheckBox id="check1" Text="Display Only Parts Below Threshold" TextAlign="Right" AutoPostBack="True" OnCheckedChanged="ReRun_Main" runat="server" />
<asp:TextBox ID="txtFind" Text="Enter Part Number" runat="server" />
<asp:Button ID="btnFind" Text="Search" runat="server" OnClick="SearchTable" />
</div>

<% Dim scrollPosURL As String = "../includes/ScrollPos.htc"%>
<input id="saveScrollPos" type="hidden" runat="server" name="saveScrollPos"/>

<input name="txtWatermark" id="txtWatermark" value="Type something here" type="text"/>

<table border="0" cellspacing="0" align="center" style="border-collapse:collapse;position:relative;left:-9">
<tr>
<td>
<div style="OVERFLOW: auto; HEIGHT: 400px; vertical-align: top; ">
<ASP:DATAGRID ID="dgTable" HorizontalAlign="Center" runat="server" AutoGenerateColumns="False" ShowHeader="True" OnItemDataBound="DataGrid1_ItemDataBound">
<AlternatingItemStyle BackColor = "#eeeeee" />
<HEADERSTYLE CssClass="ms-formlabel DataGridFixedHeader" />
<COLUMNS>

<ASP:BOUNDCOLUMN HEADERTEXT="PN" DATAFIELD="PART_NUM" READONLY="true" ItemStyle-Width="130px" ItemStyle-Font-Size="8"/>
<ASP:BOUNDCOLUMN HEADERTEXT="PART_DESC" DATAFIELD="PART_DESC" READONLY="true" ItemStyle-Width="150px" ItemStyle-Font-Size="8"/>
<ASP:BOUNDCOLUMN HEADERTEXT="numFailed" DATAFIELD="NUM_FAILED" READONLY="true" ItemStyle-Width="150px" ItemStyle-Font-Size="8"/>
<ASP:BOUNDCOLUMN HEADERTEXT="AvgCensus" DATAFIELD="AVG_CENSUS" READONLY="true" ItemStyle-Width="150px" ItemStyle-Font-Size="8"/>
<ASP:BOUNDCOLUMN HEADERTEXT="PartMultiplier" DATAFIELD="PartMultiplier" READONLY="true" ItemStyle-Width="150px" ItemStyle-Font-Size="8"/>
<ASP:BOUNDCOLUMN HEADERTEXT="ReliabilityRate" DATAFIELD="RELIABILITY_RATE" READONLY="true" ItemStyle-Width="105px" ItemStyle-Font-Size="8"/>
<ASP:BOUNDCOLUMN HEADERTEXT="PRIORITY" DATAFIELD="PRIORITY" READONLY="true" Visible="False" ItemStyle-Width="0px" ItemStyle-Font-Size="8"/>
<ASP:BOUNDCOLUMN HEADERTEXT="Criticality" DATAFIELD="Criticality" READONLY="true" ItemStyle-Width="105px" ItemStyle-Font-Size="8"/>
</COLUMNS>
</ASP:DATAGRID>
</div>
</td>
</tr>
</table>
</form>
<!-- Javascript at the bottom for fast page loading -->
<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if necessary -->
<script src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.js" type="text/javascript"></script>
<script type="text/javascript"> window.jQuery || document.write('<script src="js/libs/jquery-1.6.1.js">\x3C/script>')</script>

<!-- Scripts concatenated -->
<script src="js/plugins.js" type="text/javascript"></script>
<script src="js/script.js" type="text/javascript"></script>
<!-- End scripts -->

</body>
</html>

最佳答案

看看这个 working jsFiddle demo :

HTML:

<input name="status" id="status" value="Type something here" type="text"/>

CSS:

#status{
width:150;
padding:5px;
outline:none;
height:20px;
}
.focusField{
border:solid 2px #73A6FF;
background:#EFF5FF;
color:#000;
}
.idleField{
background:#EEE;
color: #6F6F6F;
border: solid 2px #DFDFDF;
}

jQuery:

var $input = $("#status"),
defaultVal = $input[0].defaultValue;

$input.addClass("idleField");

$input.focus(function() {

$input.toggleClass("idleField focusField");

if ($input.val() === defaultVal) { $input.val(""); }
else { $input.select(); }

});

$input.blur(function() {

$input.toggleClass("focusField idleField");
if ($.trim($input.val()) === "") { $input.val(defaultVal); }

});


<小时/>

编辑 - 根据评论,在 ASPX 文件中使用 jQuery:

    </form>

<!-- Javascript at the bottom for fast page loading -->

<!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if necessary -->
<script src="//ajax.aspnetcdn.com/ajax/jQuery/jquery-1.6.1.js" type="text/javascript"></script>
<script type="text/javascript"> window.jQuery || document.write('<script src="js/libs/jquery-1.6.1.js">\x3C/script>')</script>

<!-- Scripts concatenated -->
<script src="js/plugins.js" type="text/javascript"></script>
<script src="js/script.js" type="text/javascript"></script>
<!-- End scripts -->

</body>

在 script.js 中,您可以放置​​我上面发布的 jQuery。

关于vb.net - 如何将消失标签编程到 ASP 文本框中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6064632/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com