Questions tagged [code-behind]

Code-behind refers to code for your UI (Windows Forms, ASP.NET page, etc.) contained within a separate class file. This allows separation of the UI and the logic behind it.

Code-behind refers to code for your UI (Windows Forms, ASP.NET page, etc.) contained within a separate class file. This allows separation of the UI and the logic behind it.

1955 questions
16
votes
1 answer

Can I update the value of a WPF binding from the C# code behind?

I’m learning C# and building a UI that reads and writes integers to an XML config file. The UI uses a variety of custom user controls. I have a 3 radiobutton user control that binds to a single int variable (control returns 0,1,2). The control uses…
Danny Maher
  • 173
  • 1
  • 2
  • 6
16
votes
3 answers

How to get ListBox ItemsPanel in code behind

I have a ListBox with an ItemsPanel
Ben
  • 1,000
  • 2
  • 15
  • 36
16
votes
3 answers

In an ASP.NET website with a codebehind at what point are the .cs files compiled?

In Brief: In an ASP.net website with a code-behind, at what point are the *.cs files compiled? Context: A colleague who has since left, deployed a website with a .cs code-behind to a shared server. I have made a small change to a .cs file, which I…
Rich
  • 3,781
  • 5
  • 34
  • 56
16
votes
3 answers

How do I load user controls dynamically?

How can I load a user control[s] in a window dynamically (using code at runtime)?
Muhammad Adnan
  • 1,375
  • 6
  • 19
  • 40
15
votes
2 answers

ASP.Net Open New Tab in Browser from CodeBehind

I need to open a browser tab from a link that is given to me by an asp.net code behind. Normally I would have a link and target="_blank", but the link that I need is dynamic, so I must have the behavior of a _blank link from code behind. Any Ideas?
PassionateDeveloper
  • 14,558
  • 34
  • 107
  • 176
14
votes
4 answers

Setting Validation error template from code in WPF

I have a TextBox in my WPF app. I have defined a ControlTemplate for validation error as follows:
14
votes
2 answers

WPF: Referencing app-wide resources in code-behind

I have made my own custom converter which given a string returns a Brush. Now I'm able to return constant brushes such as Brushes.Red etc., but I really want to use my own colors which I have defined in an application-wide resource. How do I…
Deniz Dogan
  • 25,711
  • 35
  • 110
  • 162
14
votes
1 answer

How to Set Image Resource URI from Code-Behind

I am trying to embed a PNG graphic into a DLL and load it into an Image control as a BitmapImage. However, WPF keeps throwing an exception saying that the resource cannot be found. First, some minimal sample code and the steps to reproduce the…
O. R. Mapper
  • 20,083
  • 9
  • 69
  • 114
14
votes
2 answers

Finding the default style for a type in code behind

In WPF, you can create a Style that acts as the default for a control type in XAML: Then, when WPF goes to display that control, it looks up that Style from the resources based on the…
Tony Vitabile
  • 8,298
  • 15
  • 67
  • 123
13
votes
2 answers

code blocks are not supported in this context in asp.net control

I'm creating one html table. I want to hide the table row. I'm putting the attributes runat=server and id for the particular row, but the row has client side code in it similar to the following code. <% if ((strFlag=="d") || (strApprvdFlag=="y"))…
mathirengasamy
  • 183
  • 1
  • 2
  • 13
12
votes
2 answers

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

How I can draw a circle in WPF (without code-behind) using min(width, height)/2 as radius?
Aleksandr Vishnyakov
  • 1,872
  • 5
  • 23
  • 39
11
votes
9 answers

Passing arguments to JavaScript function from code-behind

I would like to call a javascript function from an aspx control. For instance, suppose I had: Untitled Page