This is a migrated thread and some comments may be shown as answers.

ImageManager and cast value from Page

5 Answers 46 Views
Editor
This is a migrated thread and some comments may be shown as answers.
Pierre
Top achievements
Rank 1
Pierre asked on 16 Jul 2008, 03:07 PM
Hi,

I use ImageManager as standard alone in one usercontrol. I need to cast the value from one text box in my current page to use for creating the folder to store. I try to create one public interface to make, adding in the codebehind of the page the interface and the cast in the usercontrol, but my code not compile error IMetaAuthor is not definied in the usercontrol. Any way?

aspx  is Text ID="Author"

aspx.cs

// Interface

public interface IMetaAuthor

{

MetaAuthor Author {

get; }

}


ascx : 

string Author = ((IMetaAuthor)this.Page).Author;


Regards

5 Answers, 1 is accepted

Sort by
0
Sophy
Telerik team
answered on 17 Jul 2008, 12:23 PM
Hi Pierre,

If you want to access any class or interface from several pages, you need to add it in the App_Code folder, otherwise it will be accessible only in the page in which it is defined.
Let us know if you need further assistance.

Greetings,
Sophy
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Pierre
Top achievements
Rank 1
answered on 17 Jul 2008, 01:20 PM
Hi,

I try this way during one day but no result. I need to catch the value added in the TextBox during the session of this page. Do you know one solution ?
I have one TextBox with ID="Author". The user add the name in this textBox and I need to take the value to use in the ImageManager. The problem is that this textBox is inside one another usercontrol. I have one masterpage with two usercontrols. I need to pass the value of one to another during the session of this page at screen. Could you help me
Regards


0
Sophy
Telerik team
answered on 21 Jul 2008, 12:27 PM
Hello Pierre,

Judging from your words the problem you experience is not related to the ImageManager dialog itself. You will have the same scenario if you replace the ImageManger with an ordinary UserControl. I prepared an example based on the description of your scenario. Please, find it attached. I hope it helps you achieve the desired functionality. 

Greetings,
Sophy
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Pierre
Top achievements
Rank 1
answered on 22 Jul 2008, 06:36 PM
Hi Sophy,

Thanks. I used this method but not working with my Sitefinity Cms. I have one error on line : System.NullReferenceException: Object reference not set to an instance of an object. ( Class added, sample working, Usercontrols1 and 2 changed like your sample)

error TextBox txtbox = (TextBox)Page.Master.FindControl("TextBoxControl").FindControl("Author");

I have tested many methods with no result. Tested adding textBox txtbox hidden in control to fix but nothing. After this I have used javascript to change the label with success but unable to cast from Load_Page to use in ImageManager definition. I can't pass the variable !

Help.


0
Georgi
Telerik team
answered on 18 Aug 2008, 02:19 PM
Hello Pierre,

When using FindControl in Sitefinity page, you should not look for the control in the masterpage, but rather in the IPage, because the pages are generated on the fly (they do not exists on the file system).

Sincerely yours,
Georgi
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Editor
Asked by
Pierre
Top achievements
Rank 1
Answers by
Sophy
Telerik team
Pierre
Top achievements
Rank 1
Georgi
Telerik team
Share this question
or