code-behind

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

感情迁移 提交于 2019-12-10 17:12:36
问题 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 page: this.Master.PageDescription = Constants.Titles.CardInfoPageDescription; The Constants class is compiled into App_Code.dll, which I just replaced. I've also

Adding attribute to html tag via code-behind results in error type (System.Web.UI.HtmlControls.HtmlElement) is not compatible

不想你离开。 提交于 2019-12-10 16:38:43
问题 When I try to add an attribute to my html tag in my masterpage: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" id="primtag" runat="server"> like so in code behind: prmimaryhtml_tag.Attributes.Add("lang", "en") I get this error: Parser Error Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific

Set Xamarin.Forms binding CommandParameter in code behind

与世无争的帅哥 提交于 2019-12-10 16:32:43
问题 I'm trying to set binding on a TapGestureRecognizer in code and I can't figure out the right way to do it. The working xaml looks something like this... <Grid> <Grid.GestureRecognizers> <TapGestureRecognizer Command="{Binding LaunchLocationDetailsCommand}" CommandParameter="{Binding}" /> </Grid.GestureRecognizers> </Grid> And in C#, it looks something like this... var gridTap = new TapGestureRecognizer(); gridTap.SetBinding(TapGestureRecognizer.CommandProperty, new Binding(

Why usercontrols loaded event is not fired

╄→尐↘猪︶ㄣ 提交于 2019-12-10 15:57:51
问题 I have a user control. I had this situations again some times but could always fix it by using the " New() contructor". But I still wonder what I am doing wrong because the load event has to be fired if control was loaded ! Here is some code: <Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:my="clr-namespace:OUTPUT___VideoContent" Title="OUTPUT - VideoContent" Height="350" Width="525"

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

孤者浪人 提交于 2019-12-10 15:16:13
问题 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? 回答1: On Visual studio 2010 or later, you can achieve the functionality in two ways. 1)Right click the file, select ' Exclude From Project ' 2)Right click the file,

How to access textbox, label inside update panel from code behind using asp.net web forms

早过忘川 提交于 2019-12-10 14:38:25
问题 I have a few controls defined inside an update panel which are bound to repeater control. I need to hide and show the user name and country based on anonymous fields, but the problem is that I'm not able to access the controls defined inside update panel programmatically. How can I access these controls, I looked on the net also but couldn't find many references Below is the code from aspx page and .cs page <asp:UpdatePanel ID="updPnlComments" runat="server"> <ContentTemplate> <table border=

ASP.Net VB call JavaScript function from Code Behind

白昼怎懂夜的黑 提交于 2019-12-10 13:17:03
问题 I have a function that is responsible for populating an SSRS report. The user presses a button and I go out and check to see if there is data. If no data, I provide a NO DATA message. If there is data I call the SSRS report which I would like to open in a new window. I thought using a JavaScript function would be the best way to accomplish this. How is this done or what would you recommend? Thanks in advance! <script type="text/javascript"> function openWindow(url) { document.forms[0].target

Accessing asp.net controls of datalist in codebehind

假装没事ソ 提交于 2019-12-10 12:07:42
问题 I am trying to access an asp Image tag in my code behind so that I can display a default image if there is no other image present. The problem that I am having is that I am getting an "Object reference not set to an instance of an object." error message. The aspx page <%@ Control Language="C#" AutoEventWireup="true" CodeFile="MemberProfileList.ascx.cs" Inherits="UserControls_MemberProfileList" %> <%--<asp:GridView ID="GridView1" runat="server"> </asp:GridView>--%> <asp:DataList ID=

Databinding to CLR property in code-behind

余生颓废 提交于 2019-12-09 10:25:47
问题 Binding to a Dependency Property is easy in code-behind. You just create a new System.Windows.Data.Binding object, and then call the target dependency object's SetBinding method. But how do you do this when the property which we're binding is a CLR property and you can't provide a DependencyProperty argument to SetBinding ? EDIT: The object implements INotifyPropertyChanged , if that's relevant. 回答1: Binding targets MUST be dependency properties! That's the only requirement for databinding to

Setting Validation error template from code in WPF

落花浮王杯 提交于 2019-12-09 09:23:38
问题 I have a TextBox in my WPF app. I have defined a ControlTemplate for validation error as follows: <ControlTemplate x:Key="validationTemplate"> <DockPanel LastChildFill="True"> <TextBlock DockPanel.Dock="Bottom" Text="Invalid Input: "></TextBlock> <AdornedElementPlaceholder /> </DockPanel> </ControlTemplate> My TextBox is as follows : <TextBox Validation.ErrorTemplate="{StaticResource validationTemplate}"> <TextBox.Text> <Binding Path="TEXT1" ValidatesOnDataErrors="True" validatesOnExceptions=