code-behind

Table row onclick event that runs codebehind

纵饮孤独 提交于 2019-12-06 07:50:37
I've inherited an ASP.NET project that has poorly designed HTML; in one section, the tags are wrapped with an tag to allow for "click the row to view the information" functionality. The code is: <asp:LinkButton ID="ViewArticle" runat="server" CommandName="Navigate" CommandArgument='<%# DataBinder.Eval(Container.DataItem, "id") %>' > <tr runat="server" class="list_item"> <td>some data</td> <td>some data</td> <td>some data</td> </tr> </asp:LinkButton> I'd like to do something like: <tr runat="server" class="list_item" onclick="doRowPostbackFunction('<%# DataBinder.Eval(Container.DataItem, "id")

WPF MVVM Code Behind Best Practices

﹥>﹥吖頭↗ 提交于 2019-12-06 05:26:32
问题 I'm a student learning C# with WPF using the MVVM pattern. Recently I have been working on a [art of my application (a custom splash screen) that should not be closed when I don't want it to. I have been searching the web for a good way of doing this without code-behind. Unfortunately after days I still did not find a satisfying way. Then I came to think of a way to do it myself, with help of just one line of code in the constructor of my view. It still makes my code testable and decouples

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

北慕城南 提交于 2019-12-06 05:01:32
问题 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

GridViewColumn CellTemplate Code Behind

青春壹個敷衍的年華 提交于 2019-12-06 04:16:13
问题 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

Create ControlTemplate programmatically in WPF

天涯浪子 提交于 2019-12-06 03:29:36
问题 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

How can I change the background color of a gridview cell, based on a conditional statement?

馋奶兔 提交于 2019-12-06 02:00:39
Okay I clearly haven't fed google the right query or I would've found out by now. I'm hoping someone on this forum can help me. So I have a datatable that I'm adding rows to based on a datareader that's getting its info from an sql query executed over a database. So far, so good. Now, one of those columns is called 'analysis', and I need its background color to be green if the preceding two columns are matched, and red otherwise. If I can't touch the background color, I'd like to insert a special character, any javascript that isn't interpreted as text. Simply put, I'd like css control over a

Get specific data row in gridview?

不羁岁月 提交于 2019-12-05 23:47:45
How do I get the specific data row of my GridView in asp.net? I have this image here: Example: I want to get the specific data row of the studentID = 2011017997 and its CourseNo = 'CmpE 515'; how do I get their specific data? Does GridViewRow has one of that built in functions to get the data row? Here is the aspx code: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="ValidateSubjectTeacher.aspx.cs" Inherits="SoftwareAnalysisAndDesign.SAD.ValidateSubjectTeacher" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Student Assessment Form</title>

xClassNotDerivedFromElement error when adding Code Behind to Resource Dictionary in silverlight

强颜欢笑 提交于 2019-12-05 21:34:43
问题 I need to add code behind class to Resource Dictionary as described in this question. (I know that this is not a good practise but it should work based on the comments for linked question) .I'm referencing the code with x:Class attribute: XAML (separate Resource Dictionary file): <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" x:Class="MyNamespace.MyStandardResources"> ... </ResourceDictionary> CODE:

Draw a circle in WPF using min(width, height)/2 as radius

为君一笑 提交于 2019-12-05 17:11:31
问题 How I can draw a circle in WPF (without code-behind) using min(width, height)/2 as radius? 回答1: you can do it in pure XAML you just need to use Binding for the values. You also have to make sure that everything is named <Grid Name="grdMain"> <Grid.ColumnDefinitions> <ColumnDefinition Width="75" Name="Col1" /> <ColumnDefinition Width="100" Name="Col2" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="75" Name="Row1" /> <RowDefinition Height="100" Name="Row2" /> </Grid

How to create multiple code behind file for .aspx page

时光毁灭记忆、已成空白 提交于 2019-12-05 16:01:47
I have a situation where I need to create multiple code behind files for a single .aspx page in c# asp.net. Actually I have a web form on that huge coding is done and I need multiple developer's working on it simultaneously. How can I achieve the same? Here is the code snippet I tried Class 1 MyPartialClass.cs namespace WebApplication1 { public partial class Default : System.Web.UI.Page { protected void PrintText(string pt) { Response.Write(pt); //lblTest.Text = pt; //Can not access this label in partial class. } } } Class 2 which is Default.aspx.cs namespace WebApplication1 { public partial