Last post Mar 20, 2015 03:22 PM by Bulldog248
Mar 19, 2015 08:08 PM|Bulldog248|LINK
I'm using Visual Web Developer 2010 Express with SQL Server 2008 Express, VB.
The sub below is executed when the user selects the appropriate line in DropDownList4 (SelectedIndexChanged), no problem. What I would like to do (desperately need to do), is after the selected part PDF is opened, toggle visibility so FNameDD.visibile =
False and FName.visible = True. Adding the commands simply doesn't work.
Protected Sub DropDownList4_SelectedIndexChanged(sender As Object, e As System.EventArgs)
Dim PCB1 As String = String.Empty
If FormView1.CurrentMode = FormViewMode.ReadOnly Then
Dim FName As Label = TryCast(FormView1.FindControl("PCB_FootprintLabel"), Label)
Dim FNameDD As DropDownList = TryCast(FormView1.FindControl("DropDownList4"), DropDownList)
PCB1 = PCBpdf & FNameDD.SelectedItem.Text & ".pdf"
Response.ContentType = "application/pdf"
Context.Response.AddHeader("Content-Disposition", "attachment=" + PCB1)
asp for DropDownList4 (FNamedd):
<asp:DropDownList ID="DropDownList4" runat="server" AutoPostBack="True" Visible="False" onselectedindexchanged="DropDownList4_SelectedIndexChanged" > <asp:ListItem>-- Select Footprint to View --</asp:ListItem> </asp:DropDownList>
asp for PCB_FootprintLabel (FName):
<asp:Label ID="PCB_FootprintLabel" runat="server"
Text='<%# Bind("PCB_Footprint") %>' Width="225px" />
Yesterday I had trouble with buttonclick, today labels and dropdownlists, what tomorrow?
Mar 19, 2015 09:10 PM|oned_gk|LINK
To toogle try this
FNameDD.visibile = Not FNameDD.visibile
Mar 19, 2015 10:50 PM|Bulldog248|LINK
Sorry, but that did not work.
Perhaps a more detailed explanation is in order. In my formview I have a label (PCB_Footprintlabel) that contains footprint name(s). When the page load occurs, that footprint is evaluated to see if a PDF is on file. If it is a button becomes visible that
when pressed opens the PDF for viewing. The problem is occasionally multiple entries occur in the footprint label (this is legitimate). When that happens the check for PDF files breaks down the string and populates a dropdownlist (DropDownList4 aka FNamedd).
Each footprint that has a PDF on file is added to the dropdownlist and as long as at least one PDF is found the button to allow viewing becomes visible.
When the user presses the viewing button the label is reviewed and if it contains one footprint it is opened, no problem, If multiple footprints exist, the label becomes invisible and the dropdownlist becomes visible with the top entry being -- Select Footprint
to View --. When the user makes a selection from the dropdownlist the SelectedIndexChanged event selects the footprint from dropdownlist.selecteditem.text and opens it, no problem.
The problem is that it is now in some kind of "holding pattern" that will not allow further activity on the page. I can select another footprint for viewing but if I select "Edit" in formview the system wants to open the last PDF. If I select the button
to return to the main menu page (a simple redirect) the system wants to open the last PDF.
Yesterday I had a similar issue with buttons and the solution was to change the asp portion from:
/> to: <asp:Button
= 'none';"/> I was hoping for something similar here and tried adding the
= 'none';"/ to the dropdownlist but it did not help.
Sorry for the long winded explanation but I guess it is necessary to get to a solution.
Mar 20, 2015 03:22 PM|Bulldog248|LINK
Since I could not find a simple solution I changed the way PDFs are viewed. Instead of using the selectedindexchanged to open the PDF it now makes a "View" button visible. That button does the actual opening of files. That solved all problems except toggling
the label and dropdownlist visibilities. To solve that, I added a main button to "Reset" the page. That button toggles the visibility and turns itself off.
Long solution but it works!