C# Change Pannel Class Instead Of A Switch/if Statement?
Aug 9, 2010
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="admin.aspx.cs" Inherits="******._Default"
title="Administration"
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML
1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="mainHead" runat="server" >
<title>Administration</title>
<link rel="Stylesheet" href="../style/admin.css" />
</head>
<body>
<div class="topMenu">
<asp:Panel id="mnu0" runat="server" class="navButton">
<a href="admin.aspx" class="navLink">Admin Home</a>
</asp:Panel>
<asp:Panel id="mnu1" runat="server" class="navButton">
<a href="admin.aspx" class="navLink">User Manager</a>
</asp:Panel>
<asp:Panel id="mnu2" runat="server" class="navButton">
<a href="admin.aspx" class="navLink">Products</a>
</asp:Panel>
</div>
<br /><br />
<div class="subMenu">
<a href="products.aspx" class="subLink">Products</a> <a href="productCats.aspx" class="subLink">Categories</a>
</div>
<br /><br />
Welcome to the Admin
</body>
</html>
Code behind:
public partial class _Default : System.Web.UI.Page
{
protected int menuID;
protected void Page_Load(object sender, EventArgs e)
{
string menuIDdata = Page.Request.QueryString["mid"];
menuID = 0;
// Check the user is allowed here
if (!Roles.IsUserInRole("Admin"))
{
Response.Redirect("../default.aspx");
}
// Get the menu ID
if (int.TryParse(menuIDdata, out menuID))
{
menuID = int.Parse(menuIDdata);
}
else
{
menuID = 0;
}
mnu0.CssClass = "navButtonO";
}
}
I'm trying to change the class of the menu depending on which one is selected, but is there an elegant way to change the class instead of a switch/if statement? For example:
mnu[menuID].CssClass = "navButtonO";
Would change the class of the menu item.
View 1 Replies
Similar Messages:
May 20, 2010
My switch is based on a string, the text value of an server control. code:
[Code]....
[Code]....
View 3 Replies
Jan 28, 2011
currently i'm attempting to using a switch statement to change between time zone with a project for school.
if (extTime1.timeZone == "CDT")
{
switch (cboTimeZone.SelectedItem.ToString)
{
case "EST":
[Code]....
I can't seem to get the cboTimeZone to work correctly. I always thought SelectedItem was the correct choice in this situation.
View 2 Replies
Jan 12, 2010
I have two Main Tabs and in a TabContainer.I have 5 Second Level Tab Panels under Main Tabs.Two MainTabs work as mode: find and work:The default is Find Mode with First Tab visible.the user selects some field and the result is displayed in the same Panel in a GridView.When the user views the result it is displayed in the second TabPanel of the Second Level Tab which is then set to visible while other 3 tabs are still invisible.I want to go back to the Find mode and have it in the orignal state.Same thing with the Main Tabs:
When I am in work mode: the other 3 tabs are visible and the previous two Tabs are invisible.When I want to go back to Find Mode. I want to retain the what the user had selected in the 2nd level Tabs before moving to the Work panel.
View 3 Replies
Dec 10, 2010
i have three text fields in a page and i placed those in Update panel and that update panel is updated on cancel and submit button click event, and after insertion that record is displayed in gird it works properly but i am facing one problem that i have a common Pannel for all types of messages like(update,delete,insert,error messages) and i have define this panel in master page so how can i update that panel on update or according to my requirement .........
View 1 Replies
Feb 12, 2010
the below code is in ASPX page and that page is using master pages and the update panel is not updating the controls ..
.it is working fine in normal ASPX page with out master pages.
Lables are populating from database
<asp:Content ID="CphPageContent" ContentPlaceHolderID="CphPageContent" Runat="Server">
<asp:ScriptManager ID="smSubmitReqOne" runat="server" />
<fieldset>
.
.
.
.
.
..
<tr>
<td>Application Requester:<span>*</span></td>
<td><asp:DropDownList ID="drpApplnRequester" runat="server" AutoPostBack="true" OnSelectedIndexChanged="drpdrpApplnRequester_SelectedIndexChange">
<asp:ListItem Value="0" Text="Select"></asp:ListItem>
</asp:DropDownList>
<asp:RequiredFieldValidator ID="rfvApplnRequester" runat="server" InitialValue="0" Display=None ControlToValidate="drpApplnRequester" ErrorMessage="Select the Application Requester" Visible=true ValidationGroup="vgSubmitRequestOne"></asp:RequiredFieldValidator>
</td>
<td>
<a href="AddApplnRequester.aspx" target="name"
onclick="modalWinRequester(); ">Add Application
Requester</a>
</td>
</tr>
<asp:UpdatePanel ID="upApplnReqOwner" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="true">
<ContentTemplate>
<tr>
<td>
Application Requester E-mail:
</td>
<td>
<asp:Label ID="lblApplnReqEmail" runat="server" Text=""></asp:Label>
</td>
<td>
</td>
</tr>
<tr>
<td>
Application Requester Phone: </td>
<td>
</td>
<td>
</td>
</tr>
<asp:Label ID="lblApplnreqPhone" runat="server" Text=""></asp:Label>
</ContentTemplate>
<Triggers >
<asp:AsyncPostBackTrigger ControlID="drpApplnRequester" EventName="SelectedIndexChanged" />
</Triggers>
</asp:UpdatePanel>
protected void drpdrpApplnRequester_SelectedIndexChange(object sender, EventArgs e)
{
GPS.BusinessObjects.Users UserInfoRequester = new GPS.BusinessObjects.Users();
if (drpApplnRequester.SelectedValue.ToString() != "SELECT" && drpApplnRequester.SelectedValue.ToString() != "")
{
GPS.BusinessLogic.Users objUsers = new GPS.BusinessLogic.Users();
UserInfoRequester = objUsers.GetUserInfoByUserID(drpApplnRequester.SelectedValue.ToString());
lblApplnreqPhone.Text = UserInfoRequester.PhoneNumber;
lblApplnReqEmail.Text = UserInfoRequester.EmailId;
}
else
{ lblApplnreqPhone.Text = "";
lblApplnOwnerEmail.Text = "";
}
}
View 2 Replies
Feb 28, 2011
I'd like to have a standard sql select statement that depending on user input changes to alternative one.
I've written code similar to this:
if (something is true....)
{
SQLdataSRC1.SelectCommand = "Select *... etc";
// where SQLdataSRC1 is the name of the sql select statement datasource in the front end code.
}
I've put this code in the onload event and in the SQL datasource event handler but still it gets ignored - and only the SQL select statement in the front end code is recognised.
What am I doing wrong?
View 7 Replies
Sep 8, 2010
I have few inline sql statements with some arrays and if loops. I want to change them all into one stored procedure in SQL server 2005.
As i am learning SQL, i have got no idea about how it should be done with arrays and if loops. Is that possible to send arrays into stored procs or is there any other solution.
[code]....
View 2 Replies
Feb 15, 2010
I need to change the select statement based on selected value == Other.
I have tried the below code. It is not working.
[Code]....
View 4 Replies
Jan 6, 2011
want to change the css class of this div tag from the code
[Code]....
What is the best way to do so?
Currently how i do this is, i create html table with id & runat="server" tag and then from code behind i add rows and columns to this table, is there some better way to do this job?
View 3 Replies
Jan 3, 2010
Is it possible to change the CSS class of the validated control if it's not valid without codebehind or just with less code ex. Set automatic CSS class to "invalid" of all textboxes which have a required field validator? I don't like to make a check for each validator (isvalid) I have, manually.
View 1 Replies
Mar 10, 2011
Im using repeater to create dynamic ul li listIs it possible to control class whether item is first or last ?sth like :
class="<%# if(Container.ItemIndex == 0)
{
class = ...
[code]...
View 4 Replies
May 16, 2010
I have asp:Table with number of asp:Label inside asp:FormView, it represents short stats info.I need to set Label.CssClass to "red" if it's text isn't "0".Currently I do this on FormView.DataBound event. But think that it's better to use JavaScript and probably jQuery. How can I do that?
View 1 Replies
Feb 25, 2010
Ho to change Wizard1.ActiveStepIndex from the WZ.vb class
View 2 Replies
Apr 27, 2016
I want to change the class of an object dynamically in C#
Main Class : handleOperator objOpr = new handleOperator();
Then for object objOpr I need to access the methods for another class Class2 :
Means, I want objOpr = new Class2();
View 1 Replies
Jan 24, 2016
Is there any way to convert our class to controller in asp.net MVC ....
View 1 Replies
Aug 9, 2010
I have the following situation:My business class:
public class Foo
{
public String A {get;set;}
public DateTime B {get;set;}
// .. and other properties like
public String Intern {get;set;}
}
I'm binding that Item to a DetailsView in Editmode. (I bind a List containing a single object of Foo, becuase I do recall that I can only bind IEnumerable<> classes to the DetailView)The binding is done via a ObjectDataSource
View 1 Replies
Aug 16, 2010
I've tried setting the <pages pageBaseType="DynamicWebPage" /> value in web.config, but when I response.write out the page type, I'm still getting Microsoft.WebPages.WebPage.
I'm simply trying to sub-class WebPage and add some additional functionality such as a dynamic PageData dictionary similar to Phil Haack's dynamic ViewData dictionary.
View 3 Replies
Jul 19, 2010
to change ItemStyle-CssClass of TemplateField in the code behind?The intellisense for itemstyle in C# is read-only..
View 1 Replies
Feb 5, 2010
I have a menu generated by my cms:
<ul>
<li><a href='default.aspx?pageid=2' id='link2'>rrr</a></li>
<div runat='server' id='menu2'>
<a href='default.aspx?subpageid=8'>rrr</a>
<a href='default.aspx?subpageid=9&siteid='>rrr</a>
<a href='default.aspx?subpageid=10&siteid='>rrr</a>
<a href='default.aspx?subpageid=11&siteid='>rrr</a>
</div>
<li><a href='default.aspx?pageid=3' id='link3'>Your Services</a></li>
<li><a href='default.aspx?pageid=4' id='link4'>rrrrrr</a></li>
<div runat='server' id='menu4'><a href='default.aspx?subpageid=1'>Single Equality Scheme</a>
<a href='default.aspx?subpageid=2&siteid='>Diversity Strands</a>
<a href='default.aspx?subpageid=3&siteid='>Equality Impact Assessments</a>
<a href='default.aspx?subpageid=4&siteid='>Quality and Safety Committee</a>
</div>
<li><a href='default.aspx?pageid=9' id='link9'>Contact Us</a></li>
</ul>
I would like to change the link that has been clicked, to class="active". I would like to add a class to the div if the page above is clicked too.
If (Len(Request.QueryString("pageid")) <> 0 and Request.QueryString("pageid") = 4) Then
menu & Request.QueryString("pageid") & .Attributes.Add("class", "active")
link & Request.QueryString("pageid") & .Attributes.Add("class", "activelink")
end if
View 3 Replies
Dec 11, 2010
I've an usercontrol:
[Code]....
in code behind
[Code]....
I want to assign Class="current" to <a> tag to itemtemplate = CurrentTabName property
In ItemDataBound event:
[Code]....
How I can assign Class="current" to tag <a> of itemtemplate?
View 1 Replies
May 24, 2010
I am facing challenge of changing action attribute of html form tag. As my application is on shared hosting (medium trust) environment of godaddy server, I cannot use reflection to get control adapter of html tag page. So, I cannot use the following code in my Url Rewriting module.
[Code]....
Is there any otherway to implement the same functionality without reflection?
View 4 Replies
Jan 21, 2010
I'm trying to change the CSS class of the row that is in edit mode. I've managed to get it working, but it only works for alternate rows. I'm totally stumped as to what could be causing it to behave like that. I've attached what I think is the relevant code below
[Code]....
protected void grdList_RowCreated(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
e.Row.CssClass = "row";
}
if (e.Row.RowState == DataControlRowState.Edit)
{
e.Row.CssClass = "rowEdit";
}
}
.grdView tr.row:hover
{
background-color: #999999;
font-weight:bold;
}
.grdView tr.editRow
{
background-color: #999999;
font-weight:bold;
}
.rowEdit
{
background-color: #999999;
font-weight:bold;
}
.grdView .row .edit, .grdView .row .delete
{
display:none;
}
.grdView tr.row:hover td .edit, .grdView tr.row:hover td .delete
{
display:inline;
}
View 3 Replies
Feb 9, 2010
I'm dynamically binding tables and sub tables using nested listviews. On the client side I have a piece of jQuery that is toggling the visiblity of TRs witin the tables in order to provide a group expand / contract view option.
On postback I'm obviously loosing my class changes that I have applied via jQuery. I'm wondering what the best approach to maintaining these client side class changes is? I've considered creating a hidden input control per table to store the indexes of the visible TRs at the time of expanding them. The intention being to then look for the indexes during postback / rebinding and add the visible classes to each corresponding element.
Is there a better approach or some native method of passing back the client side style / class change to the server during postbacks?
View 1 Replies
Feb 10, 2011
How can i change repeater control class depends on number of rows it contain?
View 2 Replies