Remain bootstrap tab after postback c#

后端 未结 5 1941
再見小時候
再見小時候 2020-12-09 19:44

I am currently having problem retaining the bootstrap tab after my fileupload postback. The code is as follow



        
5条回答
  •  温柔的废话
    2020-12-09 19:54

    With reference to the above ideas here is how I did it (full code included)

    In your HTML Page, in the < Head > section put

    
    

    in the < body > section put a hiddenfield

    
    

    and also in the < body > section have the Bootstrap 3.0 related code

    
    

    Do not set any tab to active (this is set by the initial Value="#tab1" of the Hiddenfield).

    Then add a button to the tab2 DIV

    like so:

    (note this example is for uploading a file)

    Lastly add your c# code behind to set the value of the hiddenfield

    protected void FileUploadButton_Click(object sender, EventArgs e)
    {
          hidTAB.Value = "#tab2";
    }
    

    on posting back the JQuery will read the new value in the hiddenfield and show tab2 :)

    Hope this helps someone.

    Trev.

提交回复
热议问题