locked
How to set images to WindowsForm UITypeEditor for ASP.Net server control? RRS feed

  • Question

  • User-718569536 posted

    Hi, It's my secound time question in this forum. The topic is relating to WindowsForm UITypeEditor for ASP.NET server controls.

    If you make WindowsForm UIType Editor for ASP.Net server conttrol, they work well if you don't use any image in resource files. But, if you contains images, for example, for image property of button control, they don't work well.

    WindowsForm file with resource file can be compliled without any warning, so you might think there's no problem for this. But if you try to set the property using the WinForm editor in design mode, exception rises when you click reference button in property grid.

    In exception message, it reads "Cannot find proper resource for designated or nutral culter." (The message is shown in Japanes, so I'm afraid that my translation might be slightly different from original.)

    I'd like to have advice, information or instruction to avoid this problem.

    ------------------------------------------------
    To show practical case, I prepared a simple program and uploaded below.

    http://www.ad.il24.net/~masa_cmt/Samples/UITypeEditorTest01ex.zip <-- [Prog.01]
    http://www.ad.il24.net/~masa_cmt/Samples/WinFormUITypeEditor.zip <-- [Prog.02]

    ------------------------------------------------
    Prog.01 is ASP.Net web application, which contains ASP.Net custom server control "QuickContactsEx".
    "QuickContactsExTest.aspx" is test page for the control.

    In QuickContacts, I designated WinForm UIType editor for property "Contacts". Source code for server control is in App_Code Directory "QuickContactsEx.cs"
    In "EditValue" method of my custom editor, below line 244, I designate 2 types of WindowsForm ("ContactsCollectionSetterForm" and "ContactsCollectionSetterForm2", later contains image resources), which can be selected by #IMAGE_ATTATCH directive defined at the Top of source program.

    If #IMAGE_ATTATCH directive is no effective, UITypeEditor constructs plain text-base WindowsForm which works well. If you comment out this directive, then problem occurs. (Please try it.)

    ------------------------------------------------
    Prog.02 is Windows Form Application which is designed for designing and unit test of WindowsForm Dialog. You can confirm outlook of dialog form with image resource.
    You can adjust the program and can copy it to Prog01. As I synchronized the namespace, you don't have to do any other extra task.

    I'll appliciate any kind of information. Thank you.

    Saturday, September 5, 2009 2:24 AM

Answers

  • User-718569536 posted

    Hi Chen, Thank you for your reply. It's a simple and obvious solution. I tried and solved the problem.

    My new know-how is that we can use independent WinForm application assembly for UITypeEditor of ASP.NET Server control.

    I corrected the sample program using this policy. I've exchanged the sample program below.

    http://www.ad.il24.net/~masa_cmt/Samples/UITypeEditorTest01ex.zip <-- [Prog.01]
    http://www.ad.il24.net/~masa_cmt/Samples/WinFormUITypeEditor.zip <-- [Prog.02]

    Assembly of Prog.02 is embeded in Prog.01 WebSite's bin folder by adding reference to it. For this reason I have changed the program as follows.

    [Prog.02]
    (1) Changes namespace adding surfix ".Helper".
    (2) Changes argument type of WinForm's constructor to simple 2 dimension string array, as this program has no reference

    to class "Contact" in Prog.01.

    [Prog.01]
    (1) Open Prog.02's Dialog form in the embeded assembly.

    ------------------------------------------------
    I think it's much better to seperate WindowsForm program which is used in ASP.Net's UITypeEditor from server control's project, no matter which it contains images or not.

    Thank you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 7, 2009 10:58 AM

All replies

  • User-2106054853 posted

     Hi,

    The resx file in App_Code folder of Web Site project will not be automatically embeded into the assembly. I suggest you create a class library project for the ContactsCollectionSetterForm class. Then add the built assembly as reference of the Web Site project.

    Sunday, September 6, 2009 10:35 PM
  • User-718569536 posted

    Hi Chen, Thank you for your reply. It's a simple and obvious solution. I tried and solved the problem.

    My new know-how is that we can use independent WinForm application assembly for UITypeEditor of ASP.NET Server control.

    I corrected the sample program using this policy. I've exchanged the sample program below.

    http://www.ad.il24.net/~masa_cmt/Samples/UITypeEditorTest01ex.zip <-- [Prog.01]
    http://www.ad.il24.net/~masa_cmt/Samples/WinFormUITypeEditor.zip <-- [Prog.02]

    Assembly of Prog.02 is embeded in Prog.01 WebSite's bin folder by adding reference to it. For this reason I have changed the program as follows.

    [Prog.02]
    (1) Changes namespace adding surfix ".Helper".
    (2) Changes argument type of WinForm's constructor to simple 2 dimension string array, as this program has no reference

    to class "Contact" in Prog.01.

    [Prog.01]
    (1) Open Prog.02's Dialog form in the embeded assembly.

    ------------------------------------------------
    I think it's much better to seperate WindowsForm program which is used in ASP.Net's UITypeEditor from server control's project, no matter which it contains images or not.

    Thank you.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Monday, September 7, 2009 10:58 AM