2012-01-16 63 views
0

不能這麼難嗎?我只想在鏈接按鈕的客戶端上更改window.location,並從後面的代碼中進行設置。在LinkBut​​ton的onClientClick上設置window.location後面的代碼

lb.OnClientClick = "window.location = 'Contact.aspx'"; 

不工作,只是重新加載當前頁面。

lb.OnClientClick = "window.location = '" + Server.MapPath("Contact.aspx") + "'"; 

似乎正確解析URL(我的C盤上的開發文件夾),但拒絕我訪問!?

回答

2

如何動態地使用實例:

if (status = "fun") 
    HttpServerUtility.Transfer("fun.aspx"); 
else 
    HttpServerUtility.Transfer("sad.aspx"); 

也應該工作

lb.OnClientClick = "window.location = 'Contact.aspx'; return false;" 

原帖:

如果是在後面的代碼只是使用傳輸

HttpServerUtility.Transfer("Contact.aspx"); 

,這將通過所有形式的信息:

HttpServerUtility.Transfer("Contact.aspx",true); 

MS也對所有的選項here

+0

我不明白我怎麼可以用你的建議,在我的代碼良好的文檔?當用戶點擊它時,我需要一個鏈接按鈕導航到另一個頁面。此頁面(或OnClientClick事件)必須從我的C#代碼後面動態定義。 – 2012-01-16 12:10:31

+1

@DanielMcNulty - 我舉了一些例子。 – Hogan 2012-01-18 03:19:29

相關問題