2013-10-30 46 views
0

我的aspx頁面中有一個輸入元素。運行時不顯示Javascript調用(asp.net)

<input id="txtAllocAmt" type="text" class="txtAllocAmt" tabindex="2" size="10" name="Text1" 
         runat="server" disabled="disabled" onfocus="javascript:SetOldAllocAmt(this.id);" 
        onblur="ValidateAllocAmt(this.id);" /> 

的問題是,由於某種原因,兩個「聚焦狀態」和「的onblur」 JavaScript調用不顯示時運行代碼,如下圖所示。

<input onblur="" onfocus="" id="lvLienAllocations_ctrl0_ctl00_txtAllocAmt" class="txtAllocAmt" tabIndex="2" name="lvLienAllocations$ctrl0$ctl00$txtAllocAmt" size="10" type="text"> 

出於某種原因「的onblur」和「聚焦狀態」設置爲空字符串。

什麼是阻止asp.net代碼生成器生成這些javascript調用?

+0

頂部是如何出現在ASPX標記和底部是如何呈現在瀏覽器? –

+0

你試過把'onfocus =「SetOldAllocAmt(this.id)」'? –

+0

@Yuriy Galanter:是的。 – Sung

回答

2

要麼刪除RUNAT =服務器,或添加事件背後的代碼:

lvLienAllocations.Attributes.Add("onblur", "javascript:SetOldAllocAmt(" + lvLienAllocations.ClientID + ")"; 
+0

我剛試過它,它的工作。但我仍然無法弄清楚爲什麼會發生這種情況。正如@Yuriy Galanter所說,有些東西可能會壓倒它。 – Sung

+0

不確定,但如果你想進一步挖掘它,你可以檢查你的clientidode設置,無論是在頁面指令,web.config下