I have two panel controls on my page. Both could be displayed at the same time, or one at a time, depending on the circumstances. Why is it that when both are displayed one sits on top of the other? How can i prevent that? I can't manually set a height to the panel control as some of the controls within (i.e. radiobuttonlist control) will vary in height depending on the number of items contained within. Is there a way to ensure one panel won't sit on top of another?
Jay
Hi,
have you tried using the .visible property of the controls ?
If not try it.
Hope this helps.
yes i am using that property. The problem is when i need both to display at the same time (both set to 'visible') one sits on top of the other.
jayman911:
Why is it that when both are displayed one sits on top of the other?
hi friend., try out this..
select the panels and check that theposition is selected as"not set" for both panels.
you can like this.. select panel and goto layout menu -> position -> not set should be selected.
good luck..
hope this helps..
There doesn't appear to be a 'position' property in the layout menu of the panel control. There is 'Direction' and 'Horizontal Align' and both are already set to 'not set'.
Perhaps this isn't the intended use for a panel? Is there another control i should be trying this with? A Table control perhaps? I just can't imagine that this is not the intended use of a panel control.
J
Could you please show the code for this page (aspx).
Is this what you're looking for? Notice i have a pile of "<BR />" between panels so that i can view both at the same time without overwriting each other.
J
------------------
<%@. Page Language="VB" AutoEventWireup="false" CodeFile="ViewPoll.aspx.vb" Inherits="_Default" %
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Easy Poll</title>
</head>
<body>
<form id="form1" runat="server">
<div>
</div>
<asp:Panel ID="uxViewPoll" runat="server" Height="50px" Width="300px" BackColor="#FFFFC0">
<div style="background-color:Gray">
<asp:Label ID="uxQuestion" runat="server" Width="67px"></asp:Label><br />
<asp:RadioButtonList ID="uxAnswerOptionList" runat="server" Width="251px">
</asp:RadioButtonList><br />
<asp:Button ID="uxVote" runat="server" Text="Vote!" />
</div>
</asp:Panel>
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<br />
<asp:Panel ID="uxViewResults" runat="server" Width="299px">
<asp:Label ID="uxQuestionTextResults" runat="server" Width="77px"></asp:Label><br />
<br />
<asp:DataList ID="uxResultsList" runat="server">
<ItemTemplate>
<asp:label id="uxAnswerOptionText" text='<%# eval("Text") %>' runat="server"></asp:label>
<asp:Label ID="uxVotes" Text='<%# eval("Votes") %>' runat="server"></asp:Label>
</ItemTemplate>
</asp:DataList>
</asp:Panel>
<br />
<asp:Panel ID="uxViewError" runat="server" Height="50px" Width="298px">
Error: No poll ID selected.</asp:Panel>
<br />
<br />
<br />
<br />
<br />
<br />
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</form>
</body>
</html
Please post the code in the code-behind file also. Your aspx page seems to be OK
Imports System.Data
Imports System.Data.SqlClient
Imports System.Collections.Generic
Partial Class _Default
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
' First hide all 3 panels, then selectively choose which one to display.
uxViewPoll.Visible = False
uxViewResults.Visible = False
uxViewError.Visible = False
'Check if we have a proper "pid" (PollID)
If Not (Request.QueryString.Get("pid") Is Nothing) Then
'Load the data ONLY if this is not a postback.
'If it is a postback this will be loaded in the Vote_Click
' button event handler (so that we can retrieve the selected vote first).
If Not Page.IsPostBack Then
DisplayPollData()
End If
Else 'If no "pid" then display an error message
uxViewError.Visible = True
End If
End Sub
Protected Sub uxVote_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles uxVote.Click
Poll.SubmitVote(uxAnswerOptionList.SelectedValue)
DisplayPollData()
End Sub
Private Sub DisplayPollData()
Dim myPoll As New Poll
Dim PollID As Integer = -1
'Retrieve the pollID from the url and retrieve the poll data
PollID = Request("pid")
myPoll = Poll.GetPoll(PollID, True)
' for now display both panels at the same time...
uxViewPoll.Visible = True
uxViewResults.Visible = True
'Populate the data in the uxViewPoll Panel
uxQuestion.Text = myPoll.Question
uxAnswerOptionList.DataSource = myPoll.AnswerOptions
uxAnswerOptionList.DataTextField = "Text"
uxAnswerOptionList.DataValueField = "AnswerOptionID"
uxAnswerOptionList.DataBind()
'Populate the data in the uxViewResults Panel
uxResultsList.DataSource = myPoll.AnswerOptions
uxResultsList.DataBind()
Label1.Text = myPoll.TotalVotes
End Sub
End Class
forgot to mention before i posted the above code that "myPoll" is an instance of a custom class in my business logic layer.
If i were to render all 3 panels at the same time (viewPoll, viewResults, viewError) all 3 would be rendered on top of each other.
Thanks.
J
Hi,
My suggestion is to cancel all the set of height and width, because you couldn't set it stably. Then it will be broadened automatically with numbers of your controls.
The other way is to set ScrollBars property, such as "auto". Then it will have scrollbar for you to avoid each on the top of others if you have set width and height stably.
Hope this helps.
0 comments:
Post a Comment