<uc:Tabs runat="server">
<uc:ControlA runat="server" />
<uc:ControlB runat="server" />
<uc:ControlC runat="server" />
</uc:Tabs>
I'm trying to build a "Tabs" user control that will gather all of the controls nested within itself and wrap them in a specific set of html. Each nested user control should display normally. Any pointers to where I might begin?
Edit:
<asp:Menu
id="Menu1"
StaticMenuItemStyle-CssClass="tab"
StaticSelectedStyle-CssClass="selectedTab"
CssClass="tabs"
OnMenuItemClick="Menu1_MenuItemClick"
Runat="server">
<Items>
<asp:MenuItem Text="Tab 1" Value="0" Selected="true" />
<asp:MenuItem Text="Tab 2" Value="1" />
<asp:MenuItem Text="Tab 3" Value="2" />
</Items>
</asp:Menu>
<asp:MultiView ID="MultiView1" ActiveViewIndex="0" runat="server">
<asp:View ID="View1" runat="server">
<hi5:GameInfo runat="server" />
</asp:View>
<asp:View ID="View2" runat="server">
<hi5:GamePlayerInfo runat="server" />
</asp:View>
<asp:View ID="View3" runat="server">
<hi5:GuildInfo runat="server" />
</asp:View>
</asp:MultiView>
I guess I could use asp:Menu and asp:MultiView and wrap each with the appropriate classes.
Wish I could remove the auto generated css that asp:Menu puts into the <head> though. Any idea how to do that?
Here is an MSDN VB solution which could be easily translated to C#.
http://support.microsoft.com/kb/319100
However depending on what you are trying to accomplish, this sounds like it may be an overcomplicated or overkill solution for what you are trying to do.
Related
Im trying to take some selected value to use it in an insert method I have to the database (this is working with given vaalues), now I want to give to take the value from a form. Everything's fine but the radio buttons... I do not know how to take the value :P.
Here it is:
<tr>
<td>Oral/Written Communications:</td>
<td>
<asp:RadioButton ID="form1_1" GroupName="form1" runat="server" Text="1" />
<asp:RadioButton ID="form1_2" GroupName="form1" runat="server" Text="2" />
<asp:RadioButton ID="form1_3" GroupName="form1" runat="server" Text="3" />
<asp:RadioButton ID="form1_4" GroupName="form1" runat="server" Text="4" />
<asp:RadioButton ID="form1_5" GroupName="form1" runat="server" Text="5" />
<br /></td>
</tr>
And in the backend...
int selected = form1.value
This is not working... Not even recognizing the form1. etc.... How can I handle this?
EB.
When you work with a RadioButton control, each one of them is a separate control and you need to check them like this:
string selectedValue;
if (form1_1.Checked)
selectedValue = form1_1.Text;
else if (form1_2.Checked)
selectedValue = form1_2.Text;
...
You can also go after the Request.Form collection, but I don't find it to be easy to use with RadioButton controls.
Maybe the easiest thing, if you can change the code slightly, is to use a RadioButtonList control:
<asp:RadioButtonList ID="form1list" runat="server" RepeatDirection="Horizontal" RepeatLayout="Flow">
<asp:ListItem Text="1" />
<asp:ListItem Text="2" />
<asp:ListItem Text="3" />
<asp:ListItem Text="4" />
<asp:ListItem Text="5" />
</asp:RadioButtonList>
Then you can simply refer to the control as a whole:
form1list.SelectedValue
What I want to happen is to create a statement that describes the type of work the user selects in the second dropdown list (titled workList). When the user selects one of the options from the dropdown list, I want a short text description of that work to appear where the label below it is (titled lblWork). I only have one option in the event (workListChanged) right now. Once I figure out how to make THAT display, I should be able to finish the rest. But I can't figure out how to get the label to display something based on the selection. The error I'm currently receiving is "cannot implicity convert type 'string' to 'bool' in the "if" statement in the workListChanged event.
<%# Page Language="C#" Debug="true" %>
<!DOCTYPE html>
<script runat="server">
protected void workListChanged(object sender, EventArgs e)
{
if (workList.SelectedItem.Text = "Office Work")
lblWork.Text = "You prefer to stay inside and code your life away.";
}
</script>
<html>
<head id="Head1" runat="server">
<title>Personality Test</title>
<style>
ul {
list-style-type: none;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label id="lblName"
Text="Name"
AssociatedControlID="txtName"
runat="server" />
<asp:TextBox
id="txtname"
AutoPostBack="true"
runat="server" />
<br /><br />
<asp:TextBox
id="textComments"
Text="Tell me a little about yourself"
TextMode="MultiLine"
Columns="30"
rows="10"
runat="server" />
<br /><br />
Select a gender:
<asp:RadioButton
id="rd1Male"
Text="Male"
GroupName="rgGender"
runat="server" />
<asp:RadioButton
id="rd1Female"
Text="Female"
GroupName="rgGender"
runat="server" />
<br /><br />
<strong>Favorite Season:</strong>
<br />
<asp:DropDownList
id="DropDownList1"
Runat="server"
AutoPostBack="true"
>
<asp:ListItem Text="Spring" />
<asp:ListItem Text="Summer" />
<asp:ListItem Text="Autumn" />
<asp:ListItem Text="Winter" />
</asp:DropDownList>
<br /><br />
<strong>Which of the following colors are your favorite?</strong>
<ul>
<li>
<asp:RadioButton
id="rd1Red"
Text="Red"
GroupName="colors"
runat="server" />
</li>
<li>
<asp:RadioButton
id="rd1Blue"
Text="Blue"
GroupName="colors"
runat="server" />
</li>
<li>
<asp:RadioButton
id="rd1Purple"
Text="Purple"
GroupName="colors"
runat="server" />
</li>
<li>
<asp:RadioButton
id="rd1Yellow"
Text="Yellow"
GroupName="colors"
runat="server" />
</li>
<li>
<asp:RadioButton
id="rd1Green"
Text="Green"
GroupName="colors"
runat="server" />
</li>
<li>
<asp:RadioButton
id="rd1Orange"
Text="Orange"
GroupName="colors"
runat="server" />
</li>
<li>
<asp:RadioButton
id="rd1Violet"
Text="Violet"
GroupName="colors"
runat="server" />
</li>
<li>
<asp:RadioButton
id="rd1Pink"
Text="Pink"
GroupName="colors"
runat="server" />
</li>
<li>
<asp:RadioButton
id="rd1Brown"
Text="Brown"
GroupName="colors"
runat="server" />
</li>
<li>
<asp:RadioButton
id="d1Grey"
Text="Grey"
GroupName="colors"
runat="server" />
</li>
</ul>
<br /><br />
<strong>Which type of work do you prefer?</strong>
<br />
<asp:DropDownList
id="workList"
Runat="server"
AutoPostBack="true"
OnSelectedIndexChanged="workListChanged">
<asp:ListItem Text="Office Work" />
<asp:ListItem Text="Outdoor Work" />
<asp:ListItem Text="Investigative Work" />
<asp:ListItem Text="Working With People" />
<asp:ListItem Text="Work Requiring Travel" />
<asp:ListItem Text="Helping People" />
</asp:DropDownList>
<br />
<asp:Label
id="lblWork"
runat ="server" />
</div>
</form>
</body>
</html>
Try changing your if statement as below. You are using a = which means you are trying to assign value, rather use == for string comparison. You cannot do if (stringExpression), since an if statement only works on a boolean.
protected void workListChanged(object sender, EventArgs e)
{
if (workList.SelectedItem.Text == "Office Work")
lblWork.Text = "You prefer to stay inside and code your life away.";
}
I want to create a Master Page that has a toolbar (add,edit,delete,approve,unapprove) as well as a gridview as shown below. This Master Page will have a lot of children. I want to reused the gridview and the toolbar.. rather than adding both of them to each page i create.
<%# Master Language="VB" AutoEventWireup="false" CodeBehind="JSPSite.master.vb" Inherits="SSPayroll.JSPSite" %>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title></title>
<link href="~/Styles/Site.css" rel="stylesheet" type="text/css" />
<link href="../Styles/Style1.css" rel="stylesheet" type="text/css" />
<asp:ContentPlaceHolder ID="HeadContent" runat="server">
</asp:ContentPlaceHolder>
</head>
<body>
<form id="Form1" runat="server">
<div class="page">
<div class="header">
<div class="title">
<h1>
<asp:Image ID="Image1" runat="server" ImageUrl="~/images/GSCV1.01 - Copy.png"
Height="73px" style="margin-top: 20px" Width="428px" />
</h1>
</div>
<div class="loginDisplay">
<asp:LoginView ID="HeadLoginView" runat="server" EnableViewState="false">
<LoggedInTemplate>
<asp:Label ID="Label2" runat="server" Text="User: " Font-Names="Cambria"></asp:Label><span class="bold">
<asp:LoginName ID="HeadLoginName" runat="server" Font-Names="Cambria" />
</span> [
<asp:LoginStatus ID="HeadLoginStatus" runat="server" LogoutAction="Redirect"
LogoutPageUrl="~/" Font-Names="Cambria" Font-Size="Small" ForeColor="#D9D5D5" Font-Bold="True" LogoutText="Sign Out" />
]
<div>
</div>
</LoggedInTemplate>
<RoleGroups>
<asp:RoleGroup>
</asp:RoleGroup>
</RoleGroups>
</asp:LoginView>
<asp:Label ID="Label1" runat="server" Text="Date/Time" Font-Names="Cambria"
Font-Size="Small" ForeColor="#333333"></asp:Label>
</div>
<div class="clear hideSkiplink">
<asp:Menu ID="NavigationMenu" runat="server" CssClass="menu" EnableViewState="False"
IncludeStyleBlock="False" Orientation="Horizontal" BackColor="#FFFBD6"
DynamicHorizontalOffset="2" Font-Names="Verdana" Font-Size="0.8em"
ForeColor="#990000" StaticSubMenuIndent="10px" Enabled="True">
<DynamicHoverStyle BackColor="#990000" ForeColor="White" />
<DynamicMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<DynamicMenuStyle BackColor="#FFFBD6" />
<DynamicSelectedStyle BackColor="#FFCC66" />
<Items>
<asp:MenuItem Text="Menu1" Value="Tools">
<asp:MenuItem NavigateUrl="~/JSPayroll/Payment_Rules/PaymentRules.aspx" Text="Payment Rules" Value="Payment Rules"></asp:MenuItem>
</asp:MenuItem>
</Items>
<StaticHoverStyle BackColor="#990000" ForeColor="White" />
<StaticMenuItemStyle HorizontalPadding="5px" VerticalPadding="2px" />
<StaticSelectedStyle BackColor="#FFCC66" />
</asp:Menu>
</div>
</div>
<asp:ContentPlaceHolder ID="ToolBarPlaceHolder" runat="server" >
<asp:Panel ID="Panel1" runat="server" HorizontalAlign="Center">
<div>
<hr />
<asp:ImageButton ID="ImageButton1" runat="server" Height="48px" ImageUrl="~/IconsPack/Home.png" Width="48px" ToolTip="Home" CssClass="morph" PostBackUrl="~/JSPayroll/JSPDefault.aspx"/>
<asp:ImageButton ID="ImageButton2" runat="server" Height="48px" ImageUrl="~/IconsPack/Add.png" PostBackUrl="~/JSPayroll/Payment_Rules/PaymentRulesDetails.aspx" ToolTip="Add Record" CssClass="morph" Width="48px"/>
<asp:ImageButton ID="ImageButton3" runat="server" Height="48px" ImageUrl="~/IconsPack/Edit E.png" ToolTip="Edit Record" CssClass="morph" Width="48px" />
<asp:ImageButton ID="ImageButton4" runat="server" Height="48px" ImageUrl="~/IconsPack/ViewDetails.png" ToolTip="View Record Details" CssClass="morph" Width="48px" />
<asp:ImageButton ID="ImageButton5" runat="server" Height="48px" ImageUrl="~/IconsPack/Delete.png" ToolTip="Delete Record" CssClass="morph" Width="48px" />
<asp:ImageButton ID="ImageButton6" runat="server" Height="48px" ImageUrl="~/IconsPack/Approved.png" ToolTip="Approve Record" CssClass="morph" Width="48px"/>
<asp:ImageButton ID="ImageButton7" runat="server" Height="48px" ImageUrl="~/IconsPack/Denied.png" ToolTip="Unapprove Record" CssClass="morph" Width="48px"/>
<asp:ImageButton ID="ImageButton8" runat="server" Height="48px" ImageUrl="~/IconsPack/Update.png" ToolTip="Refresh Table" CssClass="morph" Width="48px"/>
<hr />
</div>
</asp:Panel>
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="GridViewPlaceHolder" runat="server">
<div class="EU_TableScroll" id="showData" style="display: block">
<asp:GridView ID="GridView1" runat="server" CssClass="EU_DataTable" AllowPaging="True"
PageSize="7" AutoGenerateColumns="False" EmptyDataText="No Data Available.">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:CheckBox ID="CheckBox1" runat="server" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</asp:ContentPlaceHolder>
<asp:ContentPlaceHolder ID="DataSource" runat="server">
</asp:ContentPlaceHolder>
<div class="clear">
</div>
</div>
<div class="footer">
</div>
</form>
</body>
</html>
An Example of a Child Page using the master page from above.
<%# Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/JSPayroll/JSPSite.Master" CodeBehind="PaymentRules.aspx.vb" Inherits="SSPayroll.PaymentRules" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
</asp:Content>
<asp:Content ID="DS" ContentPlaceHolderID ="DataSource" runat ="server">
<asp:EntityDataSource ID="EntityDataSource1" runat="server" ConnectionString="name=sspEntities" DefaultContainerName="sspEntities" EnableDelete="True" EnableFlattening="False" EnableInsert="True" EnableUpdate="True" EntitySetName="GeneralRules">
</asp:EntityDataSource>
</asp:Content>
Basically what i want to do is.. In my child page just configure the Data source for each page, attached it to the gridview from the master page and the preform my task.. add, edit, delete (buttons in my master page). I am new to this and dont really have an idea of how to go about this. Some help would be appreciated. Also If someone can tell me what i am doing actually makes sense rather than adding gridviews and toolbar to each page i create. Please let me know. Thank you.
EDITED - With Answer.
Dim ContentPlaceHolder As ContentPlaceHolder
Dim gv As GridView
ContentPlaceHolder = CType(Master.FindControl("GridViewPlaceHolder"), ContentPlaceHolder)
If Not ContentPlaceHolder Is Nothing Then
gv = CType(ContentPlaceHolder.FindControl("GridView1"), GridView)
If Not gv Is Nothing Then
Dim es As EntityDataSource = EntityDataSource1
gv.DataSource = es
gv.DataBind()
End If
End If
Dim ContentPlaceHolder As ContentPlaceHolder
Dim gv As GridView
ContentPlaceHolder = CType(Master.FindControl("GridViewPlaceHolder"), ContentPlaceHolder)
If Not ContentPlaceHolder Is Nothing Then
gv = CType(ContentPlaceHolder.FindControl("GridView1"), GridView)
If Not gv Is Nothing Then
Dim es As EntityDataSource = EntityDataSource1
gv.DataSource = es
gv.DataBind()
End If
End If
I have to dynamically populate a checkbox inside an update panel in a Sharepoint site.
The problem is that eventhough i clear the selections after a button is clicked,the checkbox somehow remembers the previous selections and and shows checkbox.items[i].selected as true even for the previous selections
This issue is resolved if i remove the update panel.However i cant remove the update panel coz the whole page reloads every time a selection is made
Below is my code
<div align="left">
<asp:UpdatePanel ID="UpdatePanel1" runat="server" ChildrenAsTriggers="True" >
<ContentTemplate>
<asp:CheckBoxList BackColor="White" AutoPostBack="true" ID="cbHideTabs"
runat="server" isCheckable="true" ForeColor="#0072bc" Width="300px" >
</asp:CheckBoxList>
<input type ="button" Visible ="true" ID="HideShowTabButton" value="HideShowTab" title="HideShowTab" runat="server" style="background-color: #0072bc; color: #FFFFFF;" enableviewstate="False" />
</ContentTemplate>
</asp:UpdatePanel>
</div>
</asp:Panel>
<br />
<asp:PopupControlExtender ID="PopupControlExtender1" Enableviewstate="false" runat="server" CommitProperty="value"
PopupControlID="Panel1"
Position="Bottom" TargetControlID="ShowHideLabel">
</asp:PopupControlExtender>
Can you share the code which you are using for Clearing the selection.
I modified your code and its working for me.
Code for aspx page
<%# Page Title="Home Page" Language="vb" MasterPageFile="~/Site.Master" AutoEventWireup="false"
CodeBehind="Default.aspx.vb" Inherits="UpdateCheckbox._Default" %>
<asp:Content ID="HeaderContent" runat="server" ContentPlaceHolderID="HeadContent">
</asp:Content>
<asp:Content ID="BodyContent" runat="server" ContentPlaceHolderID="MainContent">
<div>
<asp:scriptmanager ID="Scriptmanager1" runat="server"></asp:scriptmanager>
<asp:updatepanel ID="Updatepanel1" runat="server">
<ContentTemplate>
<asp:CheckBoxList ID="chkAll" BackColor="White" AutoPostBack="true"
runat="server" isCheckable="true" ForeColor="#0072bc" Width="300px" >
<asp:ListItem Enabled="true" Text="1"></asp:ListItem>
<asp:ListItem Enabled="true" Text="1"></asp:ListItem>
<asp:ListItem Enabled="true" Text="1"></asp:ListItem>
<asp:ListItem Enabled="true" Text="1"></asp:ListItem>
<asp:ListItem Enabled="true" Text="1"></asp:ListItem>
<asp:ListItem Enabled="true" Text="1"></asp:ListItem>
<asp:ListItem Enabled="true" Text="1"></asp:ListItem>
<asp:ListItem Enabled="true" Text="1"></asp:ListItem>
</asp:CheckBoxList>
<asp:Button runat="server" Text="HideShowTab" runat="server" OnClick="Clear_Click" style="background-color: #0072bc; color: #FFFFFF;" enableviewstate="False" />
</ContentTemplate>
</asp:updatepanel>
</div>
</asp:Content>
Code in vb.net
Protected Sub Clear_Click(ByVal sender As Object, ByVal e As System.EventArgs)
chkAll.ClearSelection()
End Sub
I have a chunk of code that on page load with populates some of or all of the following labels. It should have two labels per line ( needs a line break after each xData label). The problem I am having is that since the number of labels with data and set to visable on page load changes, the br / tags cause spacing issues when not all labels are visible.
<div id="Status">
<asp:Label ID="1" runat="server" Text="1:" Width="125px" Visible="false" />
<asp:Label ID="1Data" runat="server" Text="" Visible="false" />
<asp:Label ID="2" runat="server" Text="2:" Width="125px" Visible="false" />
<asp:Label ID="2Data" runat="server" Text="" Visible="false" />
<asp:Label ID="3" runat="server" Text="3:" Width="125px" Visible="false" />
<asp:Label ID="3Data" runat="server" Text="" Visible="false" />
</div>
I would like to be able to add the line breaks after each "xData" label in the code behind when the labels are filled and set to visible.
I have tried adding "\n" to the label text and\or Environment.NewLine with no luck.
Thanks for any help
The easy way...
<div id="Status">
<div id="Status1" runat="server" Visible="false">
<asp:Label ID="1" runat="server" Text="1:" Width="125px" />
<asp:Label ID="1Data" runat="server" Text="" />
</div>
<div id="Status2" runat="server" Visible="false">
<asp:Label ID="2" runat="server" Text="2:" Width="125px" />
<asp:Label ID="2Data" runat="server" Text="" />
</div>
<div id="Status3" runat="server" Visible="false">
<asp:Label ID="3" runat="server" Text="2:" Width="125px" />
<asp:Label ID="3Data" runat="server" Text="" />
</div>
</div>
The right way...
<div id="Status">
<asp:Label CssClass="statusLabel" ID="1" runat="server" Text="1:" Width="125px" Visible="false" />
<asp:Label ID="1Data" runat="server" Text="" Visible="false" />
<asp:Label CssClass="statusLabel" ID="2" runat="server" Text="2:" Width="125px" Visible="false" />
<asp:Label ID="2Data" runat="server" Text="" Visible="false" />
<asp:Label CssClass="statusLabel" ID="3" runat="server" Text="3:" Width="125px" Visible="false" />
<asp:Label ID="3Data" runat="server" Text="" Visible="false" />
</div>
/* CSS */
#Status span {
display: block;
}
#Status .statusLabel {
clear: both;
float: left;
}
I think you could do it a couple of different ways.
One option would be what #Greg points out in his comment to your post.
Another possible option would be enclosing each label in its own <div> tag with runat="server" and then make these <div>s visible when needed. The <div> should create its own line break because of the nature of a <div>
asp:Label resolves to a span in html. If you want each one to have its own line, add the css style "display:block". Usually, you can do this by setting CssClass and put display:block in that class
If you want this way, you need to use Literal control for each BR tag so that you can set it to visible/invisible based on the visibility of corresponding Label control.
Why not just add a CSS class with a display: block rule to those labels?
This is presentational, after all.
Try wrapping the labels around a <div> instead of putting a <br /> at the end. In my experience, empty <div>'s don't create that empty space.