Welcome Guest Search | Active Topics | Sign In | Register

Embedded label control Options
hunpirate
Posted: Thursday, June 14, 2007 8:26:51 AM
Rank: Advanced Member
Groups: Member

Joined: 6/14/2007
Posts: 83
Hi,

This is reply to an email conversation between support and I earlier

Here is what I am trying to do. I try to use the slide menu control to dynamically display numerous notes from a data lookup.

I was planning to create a new menu item and one submenu and one custom item “on the fly” for each record, with an embedded asp label control on each submenu where I could display the text. My first approach didn’t seemed to be working, so my first question: would it be possible to use the control at all this way? Angel


Hi Steve,

The only place you can access a CustomItem created that way is by handling ItemDataBound event. Inside that event you can then use:

e.CustomItem.FindControl("lblNote1").Text = "something";

We are switching from email based support to forum based support. So if you have any more questions, it would be highly appreciated if you can post it in the forum.

Thanks

-----Original Message-----
Subject: Embedded label control


Hi,

I'm trying to embed an asp label control to my slide menu. The page
seems to be OK, but the control do not get rendered and access it from
code behind is generating the "Object reference not set to an instance
of an object." error.

What am I doing wrong? Could someone help me?

Thanks

Sincerely,

Steve Komaromi

Network Administrator, Systems Developer
Business Risk Partners, Inc.
Tel: 1-(860)-903-0039

Here is the aspx code segment.

-
<div style="OVERFLOW: auto; WIDTH: 530px; HEIGHT: 340px">
<asp:panel id="pnlACNotesViewer" runat="server">
<AspxLab:SlideMenu id="smACNotesViewer" runat="server" Width="100%"
MenuSkinID="None" SlidePaneHeight="130">
<ItemLooks>
<aspxlab:MenuItem ItemID="_TopGroup">
<SubMenu Style-CssText="PADDING-RIGHT: 5px; PADDING-LEFT: 5px;
FONT-WEIGHT: bold; FONT-SIZE: 11px; PADDING-BOTTOM: 5px; CURSOR: hand;
PADDING-TOP: 5px; FONT-FAMILY: tahoma; BACKGROUND-COLOR: #6b7dde"
LeftIconCellWidth="13" ItemSpacing="15"></SubMenu>
</aspxlab:MenuItem>
<aspxlab:MenuItem Height="25"
HoverStyle-CssText="background-image:url(&quot;00000002&quot;);color:#42
8EFF;"
ItemID="_TopLevelItem"
NormalStyle-CssText="background-image:url(&quot;00000001&quot;);color:#2
15DC6;"

SelectedStyle-CssText="background-image:url(&quot;00000003&quot;);color:
#215DC6;">
<SubMenu Style-CssText="BORDER-TOP-WIDTH: 1px; BORDER-RIGHT:
white 1px solid; PADDING-RIGHT: 2px; PADDING-LEFT: 13px; FONT-SIZE:
11px; FONT-WEIGHT: normal; PADDING-BOTTOM: 9px; BORDER-LEFT: white 1px
solid; CURSOR: hand; COLOR: #215dc6; BORDER-TOP-COLOR: white;
PADDING-TOP: 9px; BORDER-BOTTOM: white 1px solid; FONT-FAMILY: tahoma;
BACKGROUND-COLOR: #d6dff7"
LeftIconCellWidth="19" ItemSpacing="5"></SubMenu>
</aspxlab:MenuItem>
<aspxlab:MenuItem HoverStyle-CssText="COLOR: #428eff;
TEXT-DECORATION: underline" ItemID="_Default"
NormalStyle-CssText="color:#215DC6;"></aspxlab:MenuItem>
</ItemLooks>
<TopGroup Orientation="Vertical">
<Items>
<aspxlab:MenuItem Text-Html="No Agent Company notes found">
<SubMenu>
<TemplateItem>
<CustomItem HorizontalAlign="Center">
<asp:Label ID="lblNote1" Runat="server"
Width="510"></asp:Label>
</CustomItem>
</TemplateItem>
</SubMenu>
</aspxlab:MenuItem>
</Items>
</TopGroup>
</AspxLab:SlideMenu>
</asp:panel>
</div>
-------------------------------------------------------------------------


Thanks

Steve Komaromi

Computer Systems Manager, Lead Developer
Business Risk Partners, Inc.
Tel: 1-(860)-903-0039
eo_support
Posted: Thursday, June 14, 2007 8:34:22 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
It would be a aweful waste if you want to use CustomItem to display a Label. You can just use a menu item:

Code: C#
EO.Web.MenuItem item = new EO.Web.MenuItem();
item.Text.Html = "your_note";
SlideMenu1.Items[0].SubMenu.Items.Add(item);
hunpirate
Posted: Thursday, June 14, 2007 8:40:14 AM
Rank: Advanced Member
Groups: Member

Joined: 6/14/2007
Posts: 83
I guess that it would be. As I said: that was only my first thought. The only reason why I would use the label control so the linefeeds and spaces, tabs that might coming from the dataset field would be preserved.


Thanks

Steve Komaromi

Computer Systems Manager, Lead Developer
Business Risk Partners, Inc.
Tel: 1-(860)-903-0039
eo_support
Posted: Thursday, June 14, 2007 8:46:45 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi Steve,

MenuItem.Text.Html works pretty much the same way as a Label because it takes HTML, not simple text.

Thanks
hunpirate
Posted: Thursday, June 14, 2007 9:47:06 AM
Rank: Advanced Member
Groups: Member

Joined: 6/14/2007
Posts: 83
Hi,

Yoe are right. Sorry asp label control wouldn't preserve the format, but textbox would. I tried the html, but I have problem controlling the with of the text block, multiple spaces, line feeds are gone.

Thanks


Thanks

Steve Komaromi

Computer Systems Manager, Lead Developer
Business Risk Partners, Inc.
Tel: 1-(860)-903-0039
eo_support
Posted: Thursday, June 14, 2007 9:51:11 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Try this:

MenuItem.Text.Html = "<pre>" + your_note + "</pre>";
hunpirate
Posted: Thursday, June 14, 2007 10:05:25 AM
Rank: Advanced Member
Groups: Member

Joined: 6/14/2007
Posts: 83
Hi,

Now this would take care of the formatting. Thanks. Now if I just could control the width, because setting the width of the submenu doesn't make the text wrap or seems to effect of the submenu's height.

Thanks


Thanks

Steve Komaromi

Computer Systems Manager, Lead Developer
Business Risk Partners, Inc.
Tel: 1-(860)-903-0039
eo_support
Posted: Thursday, June 14, 2007 10:09:28 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi Steve,

You can use any HTML elements that can control HTML element width (CSS, table width, etc) to take care of it. Basically it's your HTML, our menu only take whatever you gives us and display. You can try to play with that HTML directly on the form, get the correct result and then move it into the menu.

Thanks
hunpirate
Posted: Thursday, June 14, 2007 11:27:01 AM
Rank: Advanced Member
Groups: Member

Joined: 6/14/2007
Posts: 83
Hi,

I see.

I was able to control the width with "div", but it is not a wrap. The overflow still goes to the right, accessible by the horizontal scroll bar.
Table or <td> width property doesn't seem to wrap either.

I have one menu item hard coded with extended lenght of text, and it is wrapping just fine. I switch to my dinamically added menu item and it streched to the right.

Can I send the aspx page and the code behind fragment?

Thanks

Steve



Thanks

Steve Komaromi

Computer Systems Manager, Lead Developer
Business Risk Partners, Inc.
Tel: 1-(860)-903-0039
eo_support
Posted: Thursday, June 14, 2007 11:36:56 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Then it is very obvious that there is something different between your hard coded text and your dynamically added menu item text. Our menu item behaves the same regardless whether you declared it in .aspx file or dynamically creates in code. It's really very simple as to MenuItem.Text.Html ---- it displays whatever you give to it, no transformation, no make up, nothing, the whole purpose of the property is to give you full control. So when the result is different, the HTML you provided must be different.

As such I would try to use a debugger to locate that difference first.

Steve Komaromi wrote:
Hi,
I have one menu item hard coded with extended lenght of text, and it is wrapping just fine. I switch to my dinamically added menu item and it streched to the right.
hunpirate
Posted: Thursday, June 14, 2007 11:43:50 AM
Rank: Advanced Member
Groups: Member

Joined: 6/14/2007
Posts: 83
Hi,

The difference is the <pre> tag that I use to preserve the format of the incoming text as I was suggested. If I take that out from code behind, the text wraps fine, but formatting is gone. The preservation of the incoming text was the reason why I tried to use html controls at first.

Well, I guess I could write a routine to convert the spaces and linefeeds to &nbsp;'s and <br>'s, before I send it to the page. Is that the last resort?

Thanks

Steve



Thanks

Steve Komaromi

Computer Systems Manager, Lead Developer
Business Risk Partners, Inc.
Tel: 1-(860)-903-0039
eo_support
Posted: Thursday, June 14, 2007 11:46:35 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Yes. That's actually the correct way to do it. The <pre> tag is a short cut and it really meant to "preserve" everything.
hunpirate
Posted: Thursday, June 14, 2007 11:57:43 AM
Rank: Advanced Member
Groups: Member

Joined: 6/14/2007
Posts: 83
Hi,

I just quickly wrote the conversion routine, but the effect is the same. Appearently if the text to be send include html tags of any kind from codebehind, the wrapping stops.


Thanks

Steve Komaromi

Computer Systems Manager, Lead Developer
Business Risk Partners, Inc.
Tel: 1-(860)-903-0039
eo_support
Posted: Thursday, June 14, 2007 12:07:26 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
Hi Steve,

I am not sure how I can explain this....but it's really all in your hand, you have the HTML, if you want to make it wrap, you put in a table and make it wrap. If you don't want to make it wrap, put in a nowrap attribute. If you want to have a line break, put in a br element. It's pure HTML and it's really up to you to how to format it --- forget about that it is actually inside our menu item, try get all those formatting issue resolved on the form first.

Your claim about "Appearently if the text to be send include html tags of any kind from codebehind, the wrapping stops." is false. It has everything to do with the html tags you put in and it has nothing to do with codebehind.

Thanks
hunpirate
Posted: Thursday, June 14, 2007 2:04:06 PM
Rank: Advanced Member
Groups: Member

Joined: 6/14/2007
Posts: 83
Hi,

I seems that if I translate multiple spaces to string &nbsp; and so the resulting html has some repeating "&nbsp;&nbsp;" the error abot wrapping occures. If I translate only every second occurence of multiple spaces, creating html like " &nbsp; &nbsp;" the wrapping is perfect.

I tested this with menu item that was hardcoded into the html page with the same result.

I do not know what causes it, but I tell you having the string "&nbsp;&nbsp;" in text-html hard coded or sending string from codebehind that has that string causes the problem. Try it.

Thanks

Steve




Thanks

Steve Komaromi

Computer Systems Manager, Lead Developer
Business Risk Partners, Inc.
Tel: 1-(860)-903-0039
eo_support
Posted: Thursday, June 14, 2007 2:18:46 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,217
What happens if you test it on the form directly? Can you get it wrap correctly outside of the menu?


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.