code-behind

Declaring web controls in code behind or just in aspx

In .net 1.1 I seem to remember I had to declare web controls that I had put on my aspx page also in the code behind in order to access them programatically. Since working in VS 2008 I haven't had to do that - even when working with .net 2 projects. But I just imported a 1.1 project and converted it in 2008 and added a textbox with an i...

XAML or C# code-behind

I don't like to use XAML. I prefer to code everything in C#, but I think that I am doing things wrong. In which cases it is better to use XAML and when do you use C#? What is your experience? ...

What's the difference between web services and calling code-behind with ajax?

Is there any difference in using one over the other? Should I be retrieving data from a database using web services? Or is it better to call methods from code-behind (or somewhere similar) with ajax to retrieve data? ...

Can I create a cross browser compatible silverlight page without code behind?

I have been developing a silverlight page using just xaml, javascript and html (I literally only have a .html, .js and .xaml file). The problem is, I just realized that it isn't working in any browser EXCEPT Internet Explorer (7 for sure). I have too many lines of code to want to add vb.net or visual c code behind and use the html brid...

Code-behind for DataTemplate defined in a ResourceDictionary

I've defined a DataTemplate in a ResourceDictionary. The template need some data (for populating a ListBox). Previously the template was a UserControl and the data was provided by setting the DataContext property. Is there some way of using code-behind for a DataTemplate or is using an ObjectDataProvider to provide the data the only opt...

how to add a div to container div in c# code behind

ASP.NET, C# As the title suggests I was wondering if anyone knew how to programatically (c# code behind file) add a div to another a container div (in the aspx page). Thanks in advance ...

ASP.NET - Inline vs. Code-Behind

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? ...

ASP.NET Gridview assign EventHandler to child control

Hi All, I have a GridView which is databound to an XML Datasource. For one of the columns I'm using a TemplateField and within it's ItemTemplate I have a CheckBox. I need to programatically add an EventHandler to the CheckBox. I was wondering if anyone can tell me which EventHandler from the GridView to use to add a CheckedChanged Event...

Set default style for a type in code-behind

How to set the default style for a type in code-behind e.g. for <ScaleTransform x:Key="scaler" ScaleX="1.25" ScaleY="1.25" /> <Style TargetType="{x:Type ToolTip}"> <Setter Property="LayoutTransform" Value="{DynamicResource scaler}"/> </Style> I need to set the style for the tooltip in code-behind instead of in xaml. ...

Get the Style of a Control {StaticResource {x:Type TextBlock}} in code behind

I want to grab the default Style for a TextBlock in code behind without ever having adding a custom default textblock style to resources in xaml I've got a method like this: public TextBlock DrawTextBlockAtPoint(string text, Style textblockStyle) { //... } that I want to provide an override that just uses the regular TextBlock style...

How do i add a second code behind file to a xaml file?

In visual studio i want to add a second code behind file to a xaml window (my main form). i know i can have another (or as many) files that form partial parts of a class, and if they are in the same project they will be included, but can i make more than one file sit in the expander (in the solution explorer) when i expand the xaml file ...

WPF: how to check what template and style is currently used on given control from code-behind?

I have a ListBox and a lot of templates that override/extend each other. How can I check from code-behind, what template currently affects my ListBox? I can access ListBox from code-behind, its Template property gives type of control this template is for, how to get Name of this template? Same about styles. ...

WPF C# MVC/MVP pattern and user control code-behind

I am developing a large-ish application in WPF/WCF/NHibernate/etc. and have implemented the MVP pattern (although this question is still relevant to MVC) as the core architecture. It feels quite natural to extend and add functionality as well as to come back and make changes on certain bits and pieces, as far as the core architecture is...

What do people call aspx files to distinguish them from aspx.cs/aspx.vb code-behind files?

In the "code-behind" style of ASP.NET programming, you split your code into two different files, an .aspx file and an aspx.cs file. (That's for C#; for VB, it's aspx.vb instead.) Everyone seems settled on calling the .aspx.cs/.aspx.vb files "code-behind files" or just "code-behinds". The question is: Is there a similarly established term...

Is it possible to create an instance of an ASP.NET page within another page's code-behind?

I have an .aspx page that I am using to handle the layout of an order receipt. I don't ever want the user to actually go to the page, I just want to populate the fields on the page and then render the HTML into a MailMessage that gets sent of to a customer. Currently I have been able to accomplish this by using Server.Execute("~/myrece...

Custom Code Behind for DataSet

I used to be able to double-click the work area of a dataset to create and load a code-behind page for it, where i could define some custom code to modify or extend the functionality. I don't know if it's because I'm using VS 2008, but now that doesn't happen, and the only file "beneath" the xsd file is the xss code which is auto-genera...

a 3D mesh object created in behind code

Hi All, I have a 3D object created by a method in behind code - C# and want to use in XAML code in the same solution. Could one say me how to do, please. Thanks. J.R. ...

Update a field in a page, from another page in ASP.NET

Hello I want to make a link on a page that when clicked, would open another page(tab). I have already done that. Now, when the user clicks a link in the second page, I want the page to close, and a field in the first page to be updated with what the user selected in the second page. As an example, I would like to achieve the same func...

Calling javascript from code behind

I have a c# asp.net 3.5 app I am trying to open a window from code behind after a certain event. I have this but its not working and there are no errors in firebug protected override void OnPreRender(EventArgs e) { base.OnPreRender(e); if (openCredentialsWindow) { if (openCredentialsWindow_ClientI...

How to unanimate WPF DependencyProperty?

After running WPF animations on dependency properties in code behind, the dependency properties can no longer be set using SetValue. They can only be changed through animations. I want to change a dependency property, some times through short animations, sometimes immediately in code. So how can I remove the animation from a dependency...