這是一個兩個部分的問題,一個是CSS和其他與代碼隱藏.. 這裏是我的按鈕我的導航代碼...... 我似乎無法得到的CSS或編程方式更改imagebuttons圖像
<asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Buttons/upviewassets.png" OnClick="ImageButton1_Click" />
<asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="~/Buttons/upaddassets.png" OnClick="ImageButton2_Click" />
所有的按鍵並排。在的OnClick()事件我的代碼是這樣的......
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
ImageButton1.ImageUrl = "Buttons/dnviewassets.png";
ImageButton2.ImageUrl = "Buttons/upaddassets.png";
//Response.Redirect("~/WebForm1.aspx");
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
ImageButton1.ImageUrl = "Buttons/upviewassets.png";
ImageButton2.ImageUrl = "Buttons/dnaddassets.png";
//Response.Redirect("~/WebForm1.aspx");
}
當我註釋掉它的工作Response.Redirect的,但我需要能夠使用Response.Redirect,因爲這是在母版和我需要這些按鈕重定向到其他頁面,當我使用response.redirect方法運行它時,圖像不會更改。同樣,當我第一次運行時沒有使用response.redirect時,當我點擊按鈕時,它會快速跳轉並返回它應該在的位置,但之後每次都會正常工作。
因此,對於第二部分,我也嘗試使用CSS來改變imagebuttons圖像,但無法讓它工作,我已經在網上搜索,並通過教程,但即使使用代碼提供它沒有正常工作,我的按鈕不斷跳動。 我試圖模仿母版頁中的標籤外觀。
感謝
謝謝,我也會試試這個。看起來像很多工作,似乎很簡單 – Cwm
我試過你的答案,其他答案基本相同。但是當它首先加載並點擊其中的任一按鈕時,它們似乎跳出並回滾,導致這種情況的原因是什麼?我需要一個像使用ajax選項卡容器時的流體轉換 – Cwm
我將代碼從頁面中預渲染加載來停止閃爍。 – afzalulh