我的.aspx頁面中有一個隱藏變量。將代碼中的變量值傳遞給javascript
input type="hidden" runat="server" id="isdup"
現在在代碼後面我檢查某些條件並相應地爲其分配isdup值。然而,這可能對你沒有多大幫助,但這是我在代碼背後所做的。
bool exist = (from n in mCDC.NCDCPoints
where n.EVENT_TYPE_ID == eventID
where n.BeginDate == begin
where n.EndDate == end
select n).Count() > 0;
try
{
if (!exist)
{
//do this before insert so the insert will have correct values
isdup.Value = "false";
SaveAllColumnFields(ref ncdc, e);
mCDC.NCDCPoints.InsertOnSubmit(ncdc);
mCDC.SubmitChanges();
//do this after insert because it wont work until the ncdc object
//has been assigned an ID
SaveAllDynamicFields(mCDC, ref ncdc, e);
mCDC.SubmitChanges();
Grid1.CurrentPageIndex = 0;
}
else
{
isdup.Value = "true";
System.Windows.Forms.MessageBox.Show(isdup.Value);
}
現在我需要訪問JavaScript內部的isdup。然而,問題是這些值不被傳遞,isdup爲空。
var showus= document.getElementById("<%=isdup.ClientID %>").value;
alert(showus);
if(showus == "true")
{
Showduplicate();
}
那麼,請讓我知道我一直在做的錯誤?
什麼.NET版本的jQuery代碼
? 4.0解決了這些類型的問題 – NotMe 2011-05-31 21:26:51
爲什麼使用System.Windows.Forms.MessageBox是一個ASP.net應用程序? – Chandu 2011-05-31 21:27:23
你如何將isdup傳遞給視圖? – jakubmal 2011-05-31 21:27:35