code-behind

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

情到浓时终转凉″ 提交于 2019-12-24 03:25:49
问题 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. 回答1: "Code behind" runs on the server, no browser instances there to open/use. Javascript runs in the browser, on the client's computer, it can open a new tab. If you want, you will have to write a piece in C# that will generate a JavaScript snippet with the window.open Command. 回答2: Kelsey's

How do I make a reflection effect in WPF ? (from code)

冷暖自知 提交于 2019-12-24 00:23:47
问题 I need to have some mirror objects in WPF. I have a Canvas with some content, and I need 50 visual clones, and if I modify something on the source, it should be updated in these clones. I know it is easy to do in XAML by binding the Visual of a VisualBrush to the element, but can's seem to do this from code. Can anyone help ? 回答1: Ok, meanwhile I have found the solution (Via Sese). If anyone is interested, find it below: VisualBrush VisualBrush1 = new VisualBrush(); VisualBrush1.TileMode =

Inheriting code-behind class from PhoneApplicationPage's subclass

此生再无相见时 提交于 2019-12-23 22:33:26
问题 By default all code-behind classes inherit from PhoneApplicationPage . I would like to make a subclass of PhoneApplicationPage and use it as basis for my code-behind class, like so: namespace Test { public partial class HistoryRemoverPage : PhoneApplicationPage { protected override void OnNavigatedTo (NavigationEventArgs e) { if (e.NavigationMode == NavigationMode.New) NavigationService.RemoveBackEntry(); } } } namespace Test { public partial class MainPage : HistoryRemoverPage { public

ASP.NET MVC Views - Can I use code-behind

混江龙づ霸主 提交于 2019-12-23 10:49:48
问题 I am new to MVC and I notice that the view pages can look pretty nasty with all the intermixed script tags. Does it make sense to generate the HTML in a method in the view code-behind and then just insert the string result of the method as a single bit of script? For example: <div><%= GenerateTonsOfHTMLFromSomeIEnumerable() %></div> Is this contrary to the MVC philosophy? Dumb for some other reason, like performance? Does it have any merit? 回答1: It's a matter of practice. Here's an

Events rather than Commands in MVVM?

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 09:39:10
问题 It is often specified in the various tutorials of MVVM, that the goal of MVVM is not to eliminate the code-behind and that some event-handling may still be necessary in the code-behind. What are the scenarios in which you need to write events in code-behind rather than using commands in viewmodel? 回答1: In general, if your code pertains to UI logic, keep it in the view's XAML or code-behind. The view model is only responsible for bridging and binding data between the view and the model. An

ASP.NET Control not available in CodeBehind

自作多情 提交于 2019-12-23 08:01:56
问题 I drag and drop a Label control on my ABC.ASPX page.It Compiles correctly. But the control ( Label2 ) is not available in code-behind ABC.ASPX.cs for value assignment. What is the resolution? <%@ Page language="c#" CodeBehind="ABC.aspx.cs" AutoEventWireup="false" %> <asp:Label ID="Label2" runat="server" Font-Bold="True"></asp:Label> 回答1: You are probably missing an entry for this in your designer.cs file. You can either add something like this to the file: protected global::System.Web.UI

Calling the original Page_Load function from inline code

南笙酒味 提交于 2019-12-23 07:47:12
问题 I like to Monkey patch a ASPX website so that I can add stuff to the Page_Load method within a compiled assembly. My first thought was to add a script tag containing a second Page_Load method to the ASPX file like so: <script language="CS" runat="server"> void Page_Load(object sender, System.EventArgs e) { // do some stuff in addition to the original Page_Load method } </script> But it looks like only the Page_Load method from the inline code will be executed and not the one from the original

Question about ASP.NET Code Behind model

Deadly 提交于 2019-12-23 04:55:07
问题 I am thinking about the asp.net 2.0 code behind model. After I drag a button onto my Default.aspx page, I got the following declaration in my Default.aspx.designer.cs file: public partial class _Default { protected global::System.Web.UI.HtmlControls.HtmlForm form1; protected global::System.Web.UI.WebControls.Button Button1; } And now it's OK for me to write the following code in Default.aspx.cs file: protected void Button1_Click(object sender, EventArgs e) { Button1.Text = "clicked!"; } But I

call a JQuery function from code behind in C#

无人久伴 提交于 2019-12-23 02:14:14
问题 I want to call this JQuery function from C# code behind but it is not work Here is the JQuery function function showDialog(id, title) { $(id).dialog({ modal: true, minWidth: 600, title: title }); $(id).parent().appendTo($("form:first")); } and here is the code behind which i use ClientScript.RegisterClientScriptBlock(this.GetType(), "myfunction", "$(document).ready(function(){showDialog('#editCustomer','نحديث معلومات عميل');});", true); But it is not work 回答1: ScriptManager

call a JQuery function from code behind in C#

这一生的挚爱 提交于 2019-12-23 02:14:01
问题 I want to call this JQuery function from C# code behind but it is not work Here is the JQuery function function showDialog(id, title) { $(id).dialog({ modal: true, minWidth: 600, title: title }); $(id).parent().appendTo($("form:first")); } and here is the code behind which i use ClientScript.RegisterClientScriptBlock(this.GetType(), "myfunction", "$(document).ready(function(){showDialog('#editCustomer','نحديث معلومات عميل');});", true); But it is not work 回答1: ScriptManager