code-behind

how can i hide html list item <li> using c# from code behind

筅森魡賤 提交于 2019-12-05 14:05:06
I want to hide html list item that is "li" tag using C#. But i can't do this. In earlier i just hide DIV tag using c#. But i can't hide "li" tag. Please help me to do this .If you can please send your detail Explanation... This is my partial code : this.hide.style.Add("display", "none"); // Error in hide This is my html code : <li ID="hide" style="display: Block;"><a href="../list.aspx" >list Approval</a></li> Please help me to solve this issue .... GDB Add an id and runat="server" to your list item: <li id="fooItem" runat="server"> <%-- ... --%> </li> Set the visibility property from code

MVVM: Is code-behind evil or just pragmatic?

我怕爱的太早我们不能终老 提交于 2019-12-05 11:25:26
Imagine you want a Save & Close and a Cancel & Close button on your fancy WPF MVVM window? How would you go about it? MVVM dictates that you bind the button to an ICommand and inversion of control dictates that your View may know your ViewModel but not the other way around. Poking around the net I found a solution that has a ViewModel closing event to which the View subscribes to like this: private void OnLoaded(Object sender , RoutedEventArgs e) { IFilterViewModel viewModel = (IFilterViewModel)DataContext; viewModel.Closing += OnViewModelClosing; } private void OnViewModelClosing(Object

How to access span id in code behind

百般思念 提交于 2019-12-05 11:17:56
I have an asp website with the following control: <span id="expTrainingShow" class="clsLink" style="margin-left: 20px;" onclick="GridChanger();"> + Show Expired Continuing Education</span> I want to hide this based on a condition set in the code behind. Can I access a span id like that? (the website is built using visual basic) You can use a Label instead of a html-span (which is also rendered as span) or you could add runat="server" . <span id="expTrainingShow" runat="server" class="clsLink" style="margin-left: 20px;" onclick="GridChanger();" ></span> somewhere in codebehind(the span is a

ASP.NET - Inline vs. Code-Behind

跟風遠走 提交于 2019-12-05 09:04:28
I realize that by asking this question, I could have started the apocalypse, but a colleague of mine uses a lot of inline coding in their aspx pages, where as I prefer using the code-behind. Is there a right and a wrong way here? Not unless your coding standard says otherwise. IMO code-behind helps separation of concerns, so I prefer that, but sometimes just dealing with one file is nice too. Code-behind is the more traditional and logical place. If it works, it works, but I can't stand doing it in the aspx. Kelsey I made the exact post a while back: OnDataBinding vs Inline: pros, cons and

Only Content Controls are Allowed (C# webcontrols)

江枫思渺然 提交于 2019-12-05 05:54:38
So, I'm not sure what's going on. My boss wasn't pleased with me using MVC and Razor, so I'm being forced to code with this nasty webcontrol/codebehind style. =/ The error is: Only Content controls are allowed directly in a content page that contains Content controls. Here is the masterpage: <%@ Master Language="C#"%> <!DOCTYPE html> <html> <head> <title>Application Form</title> </head> <body> <div id="container"> <asp:contentplaceholder id="contentPlaceHolder" runat="server" /> </div> </body> </html> And here is the Default.aspx page that's throwing the error. <%@ Page Language="C#" Inherits=

checkboxlist items as checked by default in codebehind asp.net

a 夏天 提交于 2019-12-05 03:19:35
In my page I have a CheckBoxList control and I have 7 items on it. I would like to set those 7 items as checked in my Page_load codebihind. my page: <asp:CheckBoxList ID="WeeklyCondition" runat="server"> <asp:ListItem Value="1">Sat</asp:ListItem> <asp:ListItem Value="2">Sun</asp:ListItem> <asp:ListItem Value="3">Mon</asp:ListItem> <asp:ListItem Value="4">Tue</asp:ListItem> <asp:ListItem Value="5">Wed</asp:ListItem> <asp:ListItem Value="6">Thu</asp:ListItem> <asp:ListItem Value="7">Fri</asp:ListItem> </asp:CheckBoxList> Majid If you want to check some of those with some condition, You can use

Access control in style from code [duplicate]

坚强是说给别人听的谎言 提交于 2019-12-04 18:51:12
This question already has an answer here: How do I access an element of a control template from within code-behind 2 answers If I have a style that defines a control template, and in this I have a control, let's say a button, is there any way to access the button from code behind of the styled control? Thank you guys! =) Say you have a style defined as follows <Style x:Key="myStyle" TargetType="{x:Type Button}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate> <Button x:Name="myTemplatedButton" Content="my templated button"/> </ControlTemplate> </Setter.Value> </Setter> </Style>

How to get values from the currently selected row within a Ext.Net.GridPanel outside of the SelectionModel?

久未见 提交于 2019-12-04 09:09:44
I have the following code within my .aspx file <ext:GridPanel runat="server" ID="GridPanel1" Height="450" Title="EmployeeList" Width = "850" Header = "false" StyleSpec = "margin: 25px;" StripeRows="true" TrackMouseOver="true" Border="true" ClicksToEdit="2"> <Store> <ext:Store ID="Store1" runat="server" DataSourceID="LinqDataSource1"> <Reader> <ext:JsonReader IDProperty="id" > <Fields> <ext:RecordField Name="id" /> <ext:RecordField Name="shortcode" /> <ext:RecordField Name="lastname" /> <ext:RecordField Name="firstname" /> <ext:RecordField Name="roomnumber" /> <ext:RecordField Name="landline" /

Create ControlTemplate programmatically in WPF

落花浮王杯 提交于 2019-12-04 07:30:25
How can I programmatically set a button's template? Polygon buttonPolygon = new Polygon(); buttonPolygon.Points = buttonPointCollection; buttonPolygon.Stroke = Brushes.Yellow; buttonPolygon.StrokeThickness = 2; // create ControlTemplate based on polygon ControlTemplate template = new ControlTemplate(); template.Childeren.Add(buttonPolygon); // This does not work! What's the right way? //create button based on controltemplate Button button = new Button(); button.Template = template; So I need a way to set my Polygon as the button's template. Suggestions? Thanks. itowlson Officially, you should

GridViewColumn CellTemplate Code Behind

╄→гoц情女王★ 提交于 2019-12-04 07:07:10
I have a listView that I construct at run-time, i.e. the columns are not known at compile-time. I would like to apply a DataTemplate to the cells such that the TextAlignment property is TextAlignment.Right. When creating the columns: foreach (var col in dataMatrix.Columns) { gridView.Columns.Add( new GridViewColumn { Header = col.Name, DisplayMemberBinding = new Binding(string.Format("[{0}]", count)), CellTemplate = getDataTemplate(count), }); count++; } private static DataTemplate getDataTemplate(int count) { DataTemplate template = new DataTemplate(); FrameworkElementFactory factory = new