codebehind

Pass objects/vars between Page_PreInit and Page_Load

I am building pages dynamically using a database to store the page info and .NET (C#) to build pages. Part of that process is to set the masterpage (in the code-behind) based on what is in the database and, as I understand it, that has to be done in Page_PreInit. My problem is how to pass objects and variables from Page_PreInit to Page...

How can I set a StackPanels margins individually?

I can set the margin of a stackpanel in code-behind like this: StackPanel sp2 = new StackPanel(); sp2.Margin = new System.Windows.Thickness(5); But how can I set each individually, both of these don't work: PSEUDO-CODE: sp2.Margin = new System.Windows.Thickness("5 0 0 0"); sp2.Margin.Left = new System.Windows.Thickness(5); ...

How can I programatically open a new page in a new tab from my codebind file in ASP.NET?

How can I programatically open a page in a new tab from my code behind file in ASP.NET after clicking on a button in my first page? Hopefully, from the new page I could also get to the Session[] array. ...

codebehind cannot reference the page controls

Hi, I have controls in ascx file but i can't see them in intellisense in .cs file.It was working nice before. I can see the control names in designer.cs file. I have deleted the Asp.net temp files in AppData folder but still not working.The other user control files in the app can reference coerrectly to it's page controls. What is the ...

How can I access my View elements via x:Name from my Presenter?

My presenter defines its own view: public SmartFormPresenter(SmartFormView view) { View = view; View.DataContext = this; } In the view I have an element with x:Name="MainTabControl": <DockPanel LastChildFill="True"> <TabControl x:Name="MainTabControl" DockPanel.Dock="Top" ItemsSource="{Binding SmartFormAreaPresenters}"> ...

Change an ASP.NET control's properties in a Repeater control

My question is fairly simple. This is what I have for the aspx page: <ul> <asp:Repeater runat="server" ID="linksList" OnItemDataBound="linksList_OnItemDataBound" > <ItemTemplate> <li><asp:HyperLink runat="server" ID="link" /></li> </ItemTemplate> </asp:Repeater> </ul> I'm trying to get a list of hyperlinks from...

ASP.NET change a Repeater's DataSource without a postback?

I have a repeater that displays some data from a SQL query: <asp:Repeater runat="server" ID="damQuickList" OnItemDataBound="damQuickList_OnItemDataBound"> <HeaderTemplate> <ul> </HeaderTemplate> <ItemTemplate> <li><asp:HyperLink runat="server" ID="damAnchor" /></li> </ItemTemplate> <FooterTemplate> ...

Unmaintainable code behind to the non-technical

How would you explain to a non-technical person why writing code (business-logic) behind the onclick event is a bad practice and leads to unmaintainable code? Edited: I have to explain management why some refactoring is needed, also why some code is not passing code review. To some people in management this only means more funding. I ca...

Access an HTML control on ASP Master Page from the code behind of a Content Page

Hi, I have an ASP.NET / C# application in which the Master Page contain the main menu of my application and several content pages that depend of this master page. I would like to highlight the menu link of my master page corresponding to the current content page displayed. To do that, I already have a CSS class dedicated to this (call...

How to bind a WPF control to the code behind?

I have this XAML: <Window x:Class="WpfBindToCodeBehind.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300" Loaded="Window_Loaded"> <StackPanel Orientation="Vertical"> <Button Name="ToggleExpa...

Why are aspx code-behind files declared as partial classes?

Why is the code behind a partial class for aspx pages? ...

What is processed first: aspx or aspx.vb code?

I wonder what is processed first: if the code placed in the aspx part (using server tags <% %>) or the code behind, because I place a variable that is filled in the Page_Load in the aspx between server tags and I'm not getting anything when there is a value. Anyone can point me in some directions like an article talking about the page l...

calling a procedure or handling in code behind - which is better?

Hi, I am working on ASP.NET 2.0 application with c# language. Can anyone tell me which is the best way of the following : scenario: I need to get data from the database and bind it to the grid view. case 1: I can use a stored procedure(for iteraing the result which is obtained from the basic query and do operations on this result set)...

Why can't I hit the event handler in the code behind doing a modal popup postback

I am basically trying to do what this article says. link text I am able to postback, but my handler is not getting hit. Any ideas? Code Behind protected void Page_Init(object sender, EventArgs e) { WireEvents(); } private void WireEvents() { btnAuthOk.Click += new EventHandler(btnAuthOk_Click); ...

WPF: CommandParameters for input bindings

Hi One of the things I really like with WPF is the extent to which my views can be built declaratively, ie. using XAML rather than code-behind. Now I'm really stumped by InputBindings, because their CommandParameters don't accept bindings. I imagine my case is pretty generic and straightforward, but I cannot see how I can do it without...

How to add and bind a cs file to an ASCX/ASPX page that doesn't alrady have one?

I know silly question but i tried looking it up on Google with no luck. ...

Extract inline C# code from apsx files

Is there a way/tool to extract inline C# code from within an ASPX file to a code-behind file? We want to separate the code from the HTML (lots of pages) in an application we inherited. ...

jquery append + code-behind

I dynamically add rows to divStaff using jquery: $("span[id$='lblAddStaff']").click(function() { //$(".staff_tpl").find("input[id$='txtRate']").val("0,00"); var staff_row = $(".staff_tpl"); staff_row.find(".staff_row").attr("id", "Emp" + counter); $("div[id$='divStaff']").append(staff_row.html()); ...

Datbinding in code behind and using Listview cause select button to be clicked twice

Hello, I have a problem using the asp:ListView component. I have a search page, where the user can search on different fields in the database. When clicking the search button I do a search in the database and binds the result to a ListView inside the click button event. The reason why I want to use a ListView for this task is that each ...

<script runat="server"> vs. code-behind file

Are there any caching/performance/significant differences between c# code placed in <script runat='server'></script> as oppose in the code-behind? ...