Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > Media Selector Control View modes: 
User avatar
Member
Member
envisasoft-msn - 8/17/2011 10:52:16 AM
   
Media Selector Control
I recently was building a custom control and decided to place the default Media Selector control on it. I then subsequently set some properties and was testing with it. Come to my amazement that the selected item is not in the Value property. I thought I had done something wrong. So I removed the ShowTextBox="false" property to see what had been selected and all of the sudden the Value property had something.

Could you please fix this? The Value property should be always filled with the selected item regardless of the text box showing. I ask this because I wanted to use a label for the selected item, so there is no confusion to the end user that its an editable path. What would even be better would be to have an object with properties maybe like either a document or media file. Then more information could be displayed from the selected item to the end user.

Thanks.

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/18/2011 3:40:52 AM
   
RE:Media Selector Control
Hi,

could you please share with us the code of your control? Or you could send it to support@kentico.com with reference to this thread.

It will help us to find out the reason of the issue.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
envisasoft-msn - 8/18/2011 9:36:17 AM
   
RE:Media Selector Control
Here is the snippets:

Web Page
....
<cms:MediaSelector ID="MediaSelector1" runat="server" ShowClearButton="false" ShowPreview="false" ShowTextBox="false" />
....
<asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" />
....

Code Behind
protected void Button1_Click (object sender, EventArgs e)
{
if (String.IsNullOrEmpty(MediaSelector1.Value))
{
return;
}
else....
}

The Value property is empty when there is no text box. When I remove the ShowTextBox="false" then the Value property is no longer empty. Here is even an additional thing to consider. The text in the TextBox iteself is different than the Value property.

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 8/22/2011 7:30:02 AM
   
RE:Media Selector Control
Hi,

thank you for your code.

When the property ShowTextBox is not set to true, the code which creates path to image is not executed. If you need to hide a textbox you can set the property to true, use your code and add following code in your control to hide the textbox:


protected void Page_Load(object sender, EventArgs e)
{
mediaSelector1.ImagePathTextBox.Attributes.Add("style", "display: none;");
}


Best regards,
Ivana Tomanickova