code-behind

Response.Redirect to Class that inherits from UI.Page?

眉间皱痕 提交于 2020-01-23 13:05:04
问题 everyone, thank for your time. Well this my problem (well it's not a probleam at all), it is possible to have a class that inherits from ui.page and then instance an object of that class and do a redirect to it ? Something like this: Public sub myMethod() Dim myPage as new myClassThatInheritsFromUIPage() Response.redirect(myPage) 'Here is one of my "no-idea" line end sub I do this in my webForm (and that what I want to do in a class that inherits from ui.page): Response.BufferOutput = True

How to copy List in C#

浪子不回头ぞ 提交于 2020-01-21 11:51:55
问题 I want to copy a List of Objects, but i keep getting references between the objects. List<MyClass> copy = original; When i change the value in the copy List, the original List ends up modified also. Is there a way to work around it? 回答1: You can do this: List<MyClass> copy = original.ToList(); This would make an element-by-element copy of the list, rather than copying the reference to the list itself. 来源: https://stackoverflow.com/questions/15330696/how-to-copy-list-in-c-sharp

How to copy List in C#

て烟熏妆下的殇ゞ 提交于 2020-01-21 11:49:18
问题 I want to copy a List of Objects, but i keep getting references between the objects. List<MyClass> copy = original; When i change the value in the copy List, the original List ends up modified also. Is there a way to work around it? 回答1: You can do this: List<MyClass> copy = original.ToList(); This would make an element-by-element copy of the list, rather than copying the reference to the list itself. 来源: https://stackoverflow.com/questions/15330696/how-to-copy-list-in-c-sharp

binding to width property in code behind

笑着哭i 提交于 2020-01-20 06:04:05
问题 I have a situation where I need to create View box with one button. The xaml for this is as below: Please observe Width property of viewbox. The Width should be increased/decreased according to a slider bar(moving to right increases it, to left decreases it). As listed below I know how to do it in xaml and it works fine. But my requirement is to be able to create viewbox in code behind and assign it the properties. <WrapPanel x:Name="_wrpImageButtons" Grid.IsSharedSizeScope="True"

Intercept selection in window.onbeforeunload dialog

白昼怎懂夜的黑 提交于 2020-01-17 03:39:31
问题 in my web application if the user leaves the current page without having saved changes in the form a pop up window is opened to alert him about that. For the pop up I use some scripts code injected from codebehind (C#): var Confirm = true; window.onbeforeunload = confirmClose; function confirmClose() { if (!Confirm) return; if(/*CHECK CHANGE CONDITION IS TRUE*/) { return " + WARN_message + "; } } I would need to intercept whether the user click on cancel or ok button. I tried like: var button

asp.net Can't find controls added from code-behind in a div

风流意气都作罢 提交于 2020-01-15 12:33:30
问题 I'm trying to access Controls in div but I can't find them. I got a div with some controls in it. <div id="divChampsFiltrageProjetsTest" class="divChampsFiltrageProjetsTest" runat="server"> <span runat="server" style="color:black;"> Filtre 1 : </span> <asp:DropDownList ID="ddlFiltreProjets1" runat="server" ForeColor="Black" > <asp:ListItem Value="no" Selected="True">No. Projet</asp:ListItem> <asp:ListItem Value="desi">Designation Projet</asp:ListItem> <asp:ListItem Value="chef">Chef de Projet

Best way to create and post a form in codebehind in C#

前提是你 提交于 2020-01-14 03:31:38
问题 I'm using webforms and I need to create and POST an http form to a payment gateway for one of my clients. I'm using a user control that is displayed in a masterpage, however they already have an existing <form> on the page, so I'm pretty sure I cannot add another. What is the best practice method to create and post a form in C# from the code behind? Currently I have the following: var nvc = new System.Collections.Specialized.NameValueCollection { {"EWAY_ACCESSCODE", ewayResponse.AccessCode},

how can i hide html list item <li> using c# from code behind

爷,独闯天下 提交于 2020-01-13 11:39:32
问题 I want to hide html list item that is "li" tag using C#. But i can't do this. In earlier i just hide DIV tag using c#. But i can't hide "li" tag. Please help me to do this .If you can please send your detail Explanation... This is my partial code : this.hide.style.Add("display", "none"); // Error in hide This is my html code : <li ID="hide" style="display: Block;"><a href="../list.aspx" >list Approval</a></li> Please help me to solve this issue .... 回答1: Add an id and runat="server" to your

checkboxlist items as checked by default in codebehind asp.net

佐手、 提交于 2020-01-13 08:46:48
问题 In my page I have a CheckBoxList control and I have 7 items on it. I would like to set those 7 items as checked in my Page_load codebihind. my page: <asp:CheckBoxList ID="WeeklyCondition" runat="server"> <asp:ListItem Value="1">Sat</asp:ListItem> <asp:ListItem Value="2">Sun</asp:ListItem> <asp:ListItem Value="3">Mon</asp:ListItem> <asp:ListItem Value="4">Tue</asp:ListItem> <asp:ListItem Value="5">Wed</asp:ListItem> <asp:ListItem Value="6">Thu</asp:ListItem> <asp:ListItem Value="7">Fri</asp

asp.net sqldatasource vs doing it in code behind

我们两清 提交于 2020-01-11 10:25:10
问题 This is probably going to boil down to a philosophical question more than anything, but is there really any major difference between using the <asp:sqldatasource> in the aspx file versus doing all of the work in the code behind? If so what are they and why? I know I have my preferences, but I am just curious what others think. Edit: I purposely didn't put my preference in which is to put as much as possible in the code behind or even DAO. I was curious what others thought since I am going to