code-behind

Creating a XAML Resource from Code Without a Key

Is there a way to add a resource to a ResourceDictionary from code without giving it a resource key? For instance, I have this resource in XAML: <TreeView.Resources> <HierarchicalDataTemplate DataType="{x:Type xbap:FieldPropertyInfo}" ItemsSource="{Binding Path=Value.Values}"> <TextBlock Text="{Binding Path=Name...

How to exclude ASP.NET web site code-behind files from compile?

I am refactoring a stack of ASP.NET pages. I'd like to compile and test the ones I've completed. However, Visual Studio won't let me run the Web Site with compile errors on the non-refactored pages. How can I temporarily exclude them without removing them from the project itself? Can you do so through configuration of some sort? ...

Disabling all but one control in a WPF window

I have a bunch of controls on my window. One of them is a refresh button that performs a cumbersome task on a background thread. When the user clicks the refresh button, I put the cursor in a wait (hourglass) status and disable the whole window -- Me.IsEnabled = False. I'd like to support cancellation of the refresh action by letting ...

ASP.NET MVC Views - Can I use code-behind

I am new to MVC and I notice that the view pages can look pretty nasty with all the intermixed script tags. Does it make sense to generate the HTML in a method in the view code-behind and then just insert the string result of the method as a single bit of script? For example: <div><%= GenerateTonsOfHTMLFromSomeIEnumerable() %></div> Is...

Call function in User Control from code behind of the page

Now this is all way simplified, but here goes: I have a User Control that consists only of a single *.ascx file. The control has no code-behind: it's just a script with a few functions, like this: <%@ Control Language="VB" EnableViewState="False" ClassName="MyControlType" %> <script runat="server"> Public Function MyFunction() As ...

Visual Studio 2005 stopped adding code-behind files

This morning, when I tried to add a new ASPX page to my project, Visual Studio decided that I no longer needed any .CS files associated with it. Trying to add a web control produced same results: .ascx file with no .cs. I've got two questions so far: Considering that no changes have been made to the system over the weekend, what could ...

Converting from VS 2008 Web Site to Web Application Project

I am in the process of converting a VS 2008 Web Site to a Web Application Project. I have followed the instructions on the MSDN site but am now getting a whole bunch of weird errors. I should mention that I did this for another project about a week ago and didn't have any issues. The error I am getting is this: The type 'XXX' already...

ASP.NET MVC RC - Creating a MVC User Control with a codebehind

Trying to create a MVC User Control in the Release Candidate and I can't see to make one with a codebehind file. The same is true for MVC View pages. Creating Views in the Beta would produce codebehinds...am I missing something? ...

How to get a 'codebehind' file for an ASP.NET-MVC View in RC1 to be created by default

In RC1 the behavior of the template for creating a view changed. As explained by Scott Gu's post about the release candidate a newly created aspx view doesn't have a code-behind file by default anymore. Based on feedback we’ve changed view-templates to not have a code-behind file by default. This change helps reinforce the pu...

.net development dynamically created controls need their own methods

Hello everyone, I'm sure that almost everyone programming in .net has ran into similar issues with the dynamic creation of buttons.. Example scenario.. I have a gridview and in one of the gridview fields I have a button. Normally in .net using visual studio you can easily grab the click event of the button, however since these butto...

Using Gridview in aspx.vb (code-behind)

Hey, I need to create a gridview based on 2 different datasources: main and sub-cathegory. And I need to list them like below: Productinfo sub-product 1 sub-product 2 Productinfo sub-product 1 sub-product 2 sub-product 3 sub-product 4 Etc... the thing is that both the "productinfo" and the "sub-product" are dynami...

is "non-intrusive code-behind" a good or bad practice?

I am a bit surprised that while learning WPF/XAML/Silverlight almost all of the XAML/C# examples I have encountered have the "Click" events in the XAML and very few in the Window or Page constructor. With all the emphasis these days on "non-intrusive Javascript", I would think that more developers would actually be structuring their XAM...

Referencing controls in a WPF DataTemplate

In a WPF page that I'm designing for my church, I have two ListBox controls bound to the results of two Linq-to-Entities queries: the first listbox/query contains all the folks who haven't yet pledged for the year, the second listbox/query contains all the folks who have pledged (and their associated pledges). Specifically: var familie...

how to add a code-behind page to a view or partial view

I notice with the latest version of ASP.NET MVC that a View no longer defaults to having code-behind classes. How do I go about adding a code-behind class now to a View or Partial View?? ...

Can PowerShell be used as code behind for WPF

We can use [Windows.Markup.XamlReader]::Load to load XAML file in PowerShell, but is there some way to specify some PowerShell script as code behind? ...

C#: How to convert a Website project to a Web Project

UPDATE: All of these problems was for converting a Website application to a Web Project in Visual Studio. Once I dug in and I found the solution, as I marked as answer below. Basically, if you are wanting to upgrade/move your Website project to a Web Project, you will run into a number of errors. The short how-to is in the answer belo...

[WPF] Testing the scrollbar visibility of a ListBox in code-behind

How to check whether the vertical scrollbar of the listbox is visible in code-behind? I have a listbox with x:Name="listOfItems" and its underlying ScrollViewer's VerticalScrollbarVisibility is set to auto. When the ItemsSource property of the ListBox is set, I want to check whether the verticalScrollbar is visible, but I don't know wh...

Convert a single file aspx to code behind

I'm working on a web site (not a web application) in VS 2008 .Net 3.5 and it uses the single file .aspx model where the server code is included in the head portion of the html instead of using a .aspx.cs code behind page. I'd like to quickly convert the files to use the code-behind model, but so far the only way I can do this is by rem...

Open new window from code-behind

I need to open a new window from code-behind on post-back if a specific radio button is selected. Is there any way to do this? Thank you. ...

Asp.Net (vb) Force Postback in code-behind

Hi, I'm in need of a way to force a postback or page reload in codebehind. Tried using some javascript but didn't get it to work. Browsing the net I see the first question is "why"? Circumstances are that I have a dropdownlist on autopostback, and the gridview datasource's selectparameter is derived from the selected value of that drop...