codebehind

.NET / C# String Reference in Code Behind Not Loading Updated Value

I seem to have run into a strange issue whereby a string reference is not loading an updated value. In short, I've replaced a DLL file (App_Code.dll) that contains a bunch of page titles (think HTML Page Titles), but the values aren't being updated when referenced from other DLL's. Here's a code snippet from a codebehind of a sample pa...

How do I bind to filtered or grouped Sketchflow sample data?

I've created some sample data as a StaticResource in a Sketchflow prototype (this is a Silverlight project). I want to filter or group-by the sample data before binding it to a gridview for display. How do I get at the sample data in my C# codebehind files in order to filter or group-by it before display? ...

load multiple content placeholders with user controls from server side using C#

how to load multiple content placeholders with user controls from server side using C#.. currently from serverside(in page_load) i am loading one usercontrol like this: ContentPlaceHolder cph = this.Master.FindControl("TopContentPlaceHolder") as ContentPlaceHolder; UserControl uc = this.LoadControl("~/webusercontrols/topmenu.ascx") as ...

Can i add a class to panel control in code behind?

hello all, i have a dynamic table that creates a div (new panel) for every TD and i want to give this div a class... Can i add with Attributes.Add or with cssClass a class to the panel? I am asking becouse i tried with both and got the same resault.... browser crash!!! Every other attribute works great, and i just don't understand why...

ASP.NET : Access controls declared in TemplateColumn of DataGrid

ASCX File: <asp:datagrid runat="server" id="gridFormFields" datakeyfield="FieldID" autogeneratecolumns="False" onitemcommand="gridFormFields_ItemCommand" onitemdatabound="gridFormFields_ItemDataBound"> <columns> <asp:templatecolumn> <itemtemplate> <asp:imagebutton runat="server" id="buttonMoveUpFormField" resour...

code behinde file. does it make any sense in asp.net mvc?

Hello all, I have an asp.net mvc project, its build just from views, controllers, models, and other files. I have any codebehind file in my views. Does it makes sense to create them for using sometime? Is it some situation when they giving more abilities and advantage for developer? Thanks and take care, Ragims ...

How to merge cells in a column using code behind?

C#, ASP.NET, VS08, using HTML table. I want to merge cells - rowspan and colspan spans it but does not merge it. For a clear picture, drag a HTML table control on the design view select the cells of a column right click, modify, merge I would like to do this programatically in C# coding on a button click. ...

Where to put code required by the layout in Zend Framework ?

I am using Zend_Layout for the layout of my Zend Framework application. It is very simple, but I still have a few operations that I need to do in the layout. For now, the code is included between PHP brackets, but I feel like this is not really the cleanest way to go. I saw people using plugins, but I don't think this is the way I want ...

Can two ASPX pages inherit the same code behind class?

I'm just starting out learning ASP.NET. From what I understand, ASP.NET differs from old school ASP in that the logic code for a page exists in as separate file rather then being embedded in the ASP page. So when a user requests a page like ShoppingCart.aspx the server reads the directive at the top ... <%@ Page Title="" Language="C#" M...

Greying out a button from code-behind does not work in IE

Hi, I have two drop down lists on a page. The behavior is as follows: select something in list 1 list 2 is enabled select something in list 2 button is enabled I am doing the above with autopostback enabled on the drop down lists. To toggle the button I use the code below: if (ddlAvailablePrograms.SelectedValue != string.Empty) { ...

Accessing ascx controls from a codebehind ascx.cs file

This one should be pretty simple. I am making a non-MVC ASP.NET 2.0 site. VS2008 seems to generate controls with a <script> area -- I want the code in a codebehind, so I've manually hooked that up. I have the following: widget.ascx: <%@ Control Language="C#" ClassName="widget" Codebehind="widget.ascx.cs" Inherits="widget"%> <asp:Labe...

Binding to property in nested objects in code behind.

The nested ViewModel is set to the MainWindow DataContext: var mainWindow = new MainWindow(); mainWindow.Show(); mainWindow.DataContext = new { MyProperty = new { MySubProperty = "Hello" } } It is easy to bind to MySubProperty in XAML: <Button Content="{Binding MyProperty.MySubProperty}"/> How can I do this bind...

ASP.NET app debug error

I have a web application that I am having issues with. The schema of the web application is that there are main files and sub files within sub folders. I compile the application and deploy to the webserver, which does not carry the .cs files over. When I use CodeBehind, custom user controls on the sub-files are not being found. Error: ...

i change the codebehind file, nothing happens

In asp.net WebForms I make any changes to aspx.cs file, nothing happens. R# and IntelliSense are not working too on that tab. I even can write 'blablabla' anywhere, it won't cause any errors. Seems like VS just takes the file from some other source, not the project folder, though the "CodeBehind" attribute in .aspx is written ok. I al...

FancyBox breaks input submit code behind click event

Hi guys! Not using forms!! Scenario: 1. 3 divs - div 1 and 2 display: block, div 3 display: none; User clicks on Edit - div1 and 2 display: none, div 3 display: block In div 3 i list all the articles the user has written (repeater). While repeater items are created i also create in hidden placeholder divs with textbox:header, textbo...

ASP.NET MVC2: modifying master css property depending on query string parameter

I am migrating a web site to a new one using ASP .NET MVC2. In the original site, master page has code-behind to check a query string parameter value. Depending on this value, code-behind dynamically modify some CSS property to hide / display master page elements. As MVC2 has no code-behind because we are supposed to perform everything...

How do I scan a directory for csv files, for a parser I wrote in asp.net?

Hi, I have a parser function written in my code-behind file, that takes as input the filename of a csv file, and parses the data accordingly. In the current scenario, I am supplying the name of the csv file. In a newer scenario, I would like to scan a particular local directory for csv files, and pass all of them to the parser function...

Removing the theme from one ASP.NET page in a project.

We have a page that creates a printable version of the customer's bill. We are using themes via <pages styleSheetTheme="CityDesign">. This page is not using the Master page nor has any style sheet associated with it. I have added <%@ Page Language="C#" EnableTheming="false" Theme="" %> to the page and protected void Page_PreInit(object...

ASP.NET: Call codebehind if javascript doesnt exist in browser,Else javascript function

In asp.net page, How can i call the javascript methods for form processing-submitting if the user browser supports javascript and use code behind events if the browser does not support javascript.I have the javascript code to send the form data to an ajax server page using jquery. Don't know how to invoke the needed one based on the brow...

Should I write from Controller, Code Behind, or Helper in MVC?

I've seen all the questions and answers around not having code-behind for a view, however I have a case where I need complex logic to generate the presentation (view) layer. I have to output a PDF file based on data obtained from db. Where is the best place to generate this PDF and write to the response stream? Doing response.write fr...