code-behind

Passing arguments to JavaScript function from code-behind

久未见 提交于 2019-11-26 17:00:21
问题 I would like to call a javascript function from an aspx control. For instance, suppose I had: <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title>Untitled Page</title> <script type="text/javascript"> function test(x, y) { } </script> </head> <body> <form id="form1" runat="server"> <div> <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click"/> </div> </form> </body> </html> and in the code behind: protected void Button1_Click(object sender, EventArgs

Why to avoid the codebehind in WPF MVVM pattern?

跟風遠走 提交于 2019-11-26 12:53:42
At the article, WPF Apps With The Model-View-ViewModel Design Pattern , the author who is Josh Smith said: (1) In a well-designed MVVM architecture, the codebehind for most Views should be empty, or, at most, only contain code that manipulates the controls and resources contained within that view. (2) Sometimes it is also necessary to write code in a View's codebehind that interacts with a ViewModel object, such as hooking an event or calling a method that would otherwise be very difficult to invoke from the ViewModel itself. My question is ,at the (1), why the empty codebehind is regarded as

Unable to call App_Code class from a code-behind

≡放荡痞女 提交于 2019-11-26 11:26:07
问题 I have a class in a file that\'s in the \"App_Code\" folder. I\'m able to use this in an \"aspx\" file but not from a code-behind file. How do I make it visible to a code-behind? NOTE: This is ASP.Net on Mono and I\'m writing the classes directly, not using an IDE to compile them My files: ASPX FILE (testappcode.aspx) <%@ Page language=\"c#\" src=\"TestAppCode.aspx.cs\" Inherits=\"TestAppCode.TestAppCode\" AutoEventWireup=\"true\" %> <html> <head> <title>Test App_Code Folder</title> </head>

Calling javascript from code behind

旧巷老猫 提交于 2019-11-26 09:14:22
问题 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_ClientId != Guid.Empty) { this.Page.ClientScript.RegisterStartupScript(this.GetType(), \"openCredentials\", string.Format(\"radopen(\'Services.aspx?clientId={0}, Window_Services\')\", openCredentialsWindow

ASP.NET Web Application Message Box

隐身守侯 提交于 2019-11-26 09:10:28
问题 In an asp.net windows forms application, in the C# code behind you can use: MessageBox.Show(\"Here is my message\"); Is there any equivalent in a asp.net web application? Can I call something from the C# code behind that will display a message box to the user? Example usage of this: I have a button that loads a file in the code behind. When the file is loaded or if there is an error I would like to popup a message to the user stating the result. Any ideas on this? 回答1: You want to use an

populate treeview from list of file paths in wpf

旧巷老猫 提交于 2019-11-26 07:31:57
问题 There are several examples of how to populate a tree view from a collection of file paths such as this or this other example. I cannot seem to find such example for WPF. I know I can integrate windows forms and use a different control in order to make it work but it will be nice if I could do the same thing with a wpf treeview control. The tree view that I want to construct consists of about 50,000 files therefore I think it will be better if it is bind it to something. But first before

Create DataTemplate in code behind

家住魔仙堡 提交于 2019-11-26 06:38:14
问题 How do i add controls to datatemplates programmatically? For Example. Below I\'ve created TextBlock and DataTemplate. TextBlock text = new TextBlock(); DataTemplate template = new DataTemplate(); Now I need to add TextBlock to DataTemplate. How to achieve this? I know that there are other ways of addind data template in code behind 1. create a data template in XAML and load it on code behind 2. create and add using XamlParser but i need to do in the way i showed in example. Need some help.

How do I access an element of a control template from within code-behind

☆樱花仙子☆ 提交于 2019-11-26 05:26:27
问题 I\'m trying to access a user control which is inside the control template of a content control. Specifically: <ContentControl x:Name=\"MyList\" > <ContentControl.Template> <ControlTemplate x:Name=\"MyControlTemplate\"> <Border RenderTransformOrigin=\"0,0\" x:Name=\"border\"> <UserControls:MyControl x:Name=\"MyControlName\" Width=\"100\" ViewModel=\"{Binding}\" /> I can access this.MyList but it says this.MyControlName is not found. How do I access the MyControlName object from code-behind in

Why to avoid the codebehind in WPF MVVM pattern?

扶醉桌前 提交于 2019-11-26 03:09:21
问题 At the article, WPF Apps With The Model-View-ViewModel Design Pattern, the author who is Josh Smith said: (1) In a well-designed MVVM architecture, the codebehind for most Views should be empty, or, at most, only contain code that manipulates the controls and resources contained within that view. (2) Sometimes it is also necessary to write code in a View\'s codebehind that interacts with a ViewModel object, such as hooking an event or calling a method that would otherwise be very difficult to

The name &#39;controlname&#39; does not exist in the current context

ε祈祈猫儿з 提交于 2019-11-26 00:38:30
问题 I have a web application that I\'m working on (ASP.NET2.0 with C#, using VS2005). Everything was working fine, and all of a sudden I get the error: Error 1 The name \'Label1\' does not exist in the current context and 43 others of the sort for each time that I used a control in my codebehind of the page. This is only happening for 1 page. And it\'s as if the codebehind isn\'t recognizing the controls. Another interesting thing is that the intellisense isn\'t picking up any of the controls