1

ページの読み込み時に次のスクリプトを登録しました。

    ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "watermark", "function WaterMark(txtWaterMark, event,text) { if (txtWaterMark.value.length > 0 && event.type == 'mouseover') {txtWaterMark.style.color = '#c6c1c1'; if(txtWaterMark.value == text) {txtWaterMark.value = text;} } if (txtWaterMark.value.length > 0 && event.type == 'mouseout') {txtWaterMark.style.color = 'gray';if (txtWaterMark.value.length == 0){txtWaterMark.value = text;} } if (event.type == 'focus' ) {alert(txtWaterMark.value); if(txtWaterMark.value == text){txtWaterMark.value = '';} } }", true);

この関数を aspx で作成して cs に登録できますか?

4

2 に答える 2

0

はい、あなたはこのようにすることができます

 ScriptManager.RegisterClientScriptBlock(this.GetType(), "watermark", "<script>WaterMark('watermark',event,'text')</script>");



<script>
function WaterMark(txtWaterMark, event,text) { if (txtWaterMark.value.length > 0 && event.type == 'mouseover') {txtWaterMark.style.color = '#c6c1c1'; if(txtWaterMark.value == text) {txtWaterMark.value = text;} } if (txtWaterMark.value.length > 0 && event.type == 'mouseout') {txtWaterMark.style.color = 'gray';if (txtWaterMark.value.length == 0){txtWaterMark.value = text;} } if (event.type == 'focus' ) {alert(txtWaterMark.value); if(txtWaterMark.value == text){txtWaterMark.value = '';} } }
<script>
于 2012-07-10T08:48:02.650 に答える