behavior

ListItems attributes in a DropDownList are lost on postback?

自作多情 提交于 2019-12-17 03:34:42
问题 A coworker showed me this: He has a DropDownList and a button on a web page. Here's the code behind: protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { ListItem item = new ListItem("1"); item.Attributes.Add("title", "A"); ListItem item2 = new ListItem("2"); item2.Attributes.Add("title", "B"); DropDownList1.Items.AddRange(new[] {item, item2}); string s = DropDownList1.Items[0].Attributes["title"]; } } protected void Button1_Click(object sender, EventArgs e) {

C++ differ between Linking with .o and with .a file: different behavior, why?

早过忘川 提交于 2019-12-14 03:47:23
问题 I expected that: linking with .o file, and linking with .a file archived from the .o file, should have no difference. But the fact is not. I have got 2 source files, each declaring 1class+1 static object+1 function, and a main.cpp that called one of the functions $cat First.cpp #include<stdio.h> struct First{ First(){printf("First\n");} }; void f1(){printf("f1\n");}//Not called in main static First f_obj; $cat Second.cpp #include<stdio.h> struct Second{ Second(){printf("Second\n");} }; void

Sort ignores an apostrophe - sometimes (except when it is the only column used); WHY?

我的梦境 提交于 2019-12-13 09:01:26
问题 This happens to me both on Linux and on cygwin, so I suspect it is not a bug. Still, I don't understand it. Can anyone explain? Consider the following file (tab-delimited, and that's a regular apostrophe) (I create it with cat to ensure that it wasn't non-printing characters that were the source of the problem) $cat > temp cat 1389 cat' 1747 ca't 3175 cat 46848484 ca't 720 $sort temp <gives the exact same output as cat temp> $sort -k1,1 temp cat 1389 cat 46848484 cat' 1747 ca't 3456 ca't 720

CakePHP: MeioUpload Behavior

♀尐吖头ヾ 提交于 2019-12-13 03:39:40
问题 I would like to use the [MeioUpload Behavior][1] for uploading documents like PDF, DOC, XLS etc. but I get an Invalid file type error. My Upload Model looks like this: class Upload extends AppModel { var $name = 'Upload'; var $actsAs = array( 'MeioUpload.MeioUpload' => array( 'upload_file' => array( 'dir' => 'files{DS}uploads', 'create_directory' => true, 'allowed_mime' => array('application/pdf', 'application/msword', 'application/mspowerpoint', 'application/excel', 'application/rtf',

SL4: need to register for a move (or redraw) event on an Item in an ItemsControl

老子叫甜甜 提交于 2019-12-13 03:35:46
问题 Not finding a move event or redraw event in the FrameworkElement class. And Google not helping either. So... I have a custom ItemsControl populated by an observable collection in the VM. The ItemsControl itself leverages the <i:Interaction.Behaviors> <ei:MouseDragElementBehavior ConstrainToParentBounds="True"/> </i:Interaction.Behaviors> behavior so the user can drag around the whole assembly. When the user moves the assembly, I want to be notified by each item as the item is repositioned as

JSF2 Composite component link using ajax

懵懂的女人 提交于 2019-12-13 02:27:53
问题 Here is my (simplified) issue : I've got a page that is using 2 composite components of mine : - CCSelection - CCDisplay In CCSelection, I have a list of values, each one has got a h:commandLink onto. When clicking on a link, the CCDiaplay component is refreshed using the selected value. To do this, CCSelection exposes a method attribute that is directly linked on each h:commandLink. The value is given to the method using f:attribute. In the page backing bean, I've got a method (that is given

WPF How to cast ListBox.ItemsSource into ObservableCollection<some dynamic type>

拜拜、爱过 提交于 2019-12-12 21:03:51
问题 I have written a Behavior which allows to reorder a ListBox. To work properly the ListBox's ItemsSource has to be an ObservableCollection<...>, so I can call the Move(from,to)-method. My problem is: How can I cast the ListBox.ItemsSource into a ObservableCollection. I already tried: ObservableCollection<object> test = listBox.ItemsSource as ObservableCollection<object>; which does not work, because ObservableCollection doesn't support covariance. 回答1: Since you know the method you'd like to

Specifying Castle WCF Integration Facility Endpoint Behavior per Endpoint

隐身守侯 提交于 2019-12-12 20:12:43
问题 I'm using Castle WCF Integration Facility and I have everything working properly for my first webHttp endpoint. For this endpoint to work, it requires that the endpoint have the WebHttpBehavior enabled. I was able to achieve this using: container.Register(Component.For<IEndpointBehavior>() .ImplementedBy<WebHttpBehavior>()); This becomes a problem when I try to enable a second endpoint using BasicHttpBinding which is not compatible with the WebHttpBehavior. Is there someway to specify that

How can subclasses share behavior when one already derives from a different base class?

扶醉桌前 提交于 2019-12-12 10:40:03
问题 I have two classes that implement ISomeBehavior. Now I want them to share functionality. Normally I would replace ISomeBehavior with an abstract class, like SomeBehaviorBase. The problem is that one of the subclasses already derives from another class, and that other class isn’t software we own. (This is C#, so multiple inheritance isn't an option.) The subclass, that derives from the 3rd party class, has no implementation. It simply derives from the 3rd party class, and implements

Why does Enum.Parse create undefined entries?

杀马特。学长 韩版系。学妹 提交于 2019-12-12 04:45:22
问题 class Program { static void Main(string[] args) { string value = "12345"; Type enumType = typeof(Fruits); Fruits fruit = Fruits.Apple; try { fruit = (Fruits) Enum.Parse(enumType, value); } catch (ArgumentException) { Console.WriteLine(String.Format("{0} is no healthy food.", value)); } Console.WriteLine(String.Format("You should eat at least one {0} per day.", fruit)); Console.ReadKey(); } public enum Fruits { Apple, Banana, Orange } } If you execute the code above the result shows: You