Link to home
Start Free TrialLog in
Avatar of Netlink2
Netlink2

asked on

How to hide Panel if the PARAM NAME="FileName" VALUE='no file'"

I have a video panel and I want to code in VideoPanel.visible = false if there isn't a valid video filename loaded. I want to do this in code-behind using vb.

The code is.

<asp:Panel ID="VideoPanel" runat="server">                        
      <asp:Repeater ID="VideoRepeater" runat="server" DataSourceID="AdsDataSource" OnItemDataBound="Video_ItemDataBound">
      <ItemTemplate>
      <table summary="This is a table for video preview">
      <caption class="none">Video Preview</caption>
      
      
<tbody>

<br />
      <OBJECT
                                                      
    ID="MediaPlayer"
    classid="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
    CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,715"
    width=320 height=240
    standby="Loading Microsoft Windows Media Player components..."
    type="application/x-oleobject">
    <PARAM NAME="FileName" VALUE='<%# Eval("VideoFile").ToString() %>'>
Avatar of David H.H.Lee
David H.H.Lee
Flag of Malaysia image

Dear Netlink2,
You can check the existance of the file and set the panel's visibility to false there are no file on the located at the server.
eg:

Code-behind
----------------------
If System.IO.File.Exists(Server.MapPath(YOUR_EXISTING_PARAMETER))Then
    VideoPanel.Visible=true
Else
    VideoPanel.Visible=false
End If
Avatar of Netlink2
Netlink2

ASKER

Sorry, I should have mentioned,  the file value is in a table and I don't want to duplicate calling the table because it's already called by a datalist, per the following code:
                        <asp:DataList OnItemCommand="PhotoList_ItemCommand" ID="PhotoList" runat="Server"
                              DataSourceID="PhotosDataSource" DataKeyField="Id" RepeatLayout="Flow">
                              <ItemTemplate>

                              </ItemTemplate>
                        </asp:DataList>
ASKER CERTIFIED SOLUTION
Avatar of David H.H.Lee
David H.H.Lee
Flag of Malaysia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks, so how do I know the filename in code-behind ?. The file name is different for every page which is displayed, per the table data.
Dear Netlink2,
You can use System.IO.File.Exists() to check file existance. However, i'm not sure what you meant by
>> The file name is different for every page which is displayed, per the table data.

Do you meant by the display will be different based on different filename? Please post your web layout if that the case and please give some details regarding this mentioned.
Seeing if the file exists is no problem, it's knowing which file I'm looking for which is the problem. The filename is stored as a table variable and the filename will change for every page which is shown. The filename is obtained by PhotosDataSource. So how can vb know what html knows (or the object knows), which is the name of the file ?.
I still can't hide the panel, but I'll close the question.