简体   繁体   中英

Client Side or Server side?

I am new to web development and am making an app that basically displays a listbox of documents. When the user clicks a document, that document (pdf) is displayed in an iFrame. All the documents are on a network share available from the server and client. This is only going to be used internally (intranet).

My questions are:

Should I be changing the iFrame source at the server or client? Is it even possible to do it at the client?

I am trying to do it at the server. I have the listbox set to auto postback, but I can't read the selectedindex because the page load occurs first (and reloads the listbox) and clears the selected item. If I turn auto postback for the lsitbox off, the SelectedIndexchange event never fires.

Should I be changing the iFrame source at the server or client? Is it even possible to do it at the client?

It's possible to do it at both, the server side and the client side. On the client side is done like this:

document.getElementById('frameID').src = "new_src.html";//or whatever

On the server side, you are probably doing it correctly but you are forgetting to add if(!IsPostBack) in Page_Load so that the data in the listbox is not rebound on every postback.

Something like:

protected void Page_Load(object sender, EventArgs e)
{
    if(!IsPostBack)
    {
       //populate list box
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM