473,396 Members | 1,834 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

how to set the size of the text of a label in asp.net.

Hi,

Im currently displaying a Notes contents in the text of a label. this notes column is retrieved fron the database and is of type nvarchar(2000)... and this label is currently inside a repeater. so my prob is that if the length of the notes is too long the width of the notes column increases too much thereby increasing the width of the page.. so is there way in which i could fix the size of the label text which is displayed my repeater..

Thanks,
Nitin..
Mar 15 '07 #1
6 2544
I dont think so , by default there is any function or not but you can try to use this on

in DATALIST Control there is an evet called Item Created in that event you can do one thing . check here your lable.text.lenght is more then xxx number of characters , then delete the remaining string.

Expand|Select|Wrap|Line Numbers
  1.  void Item_Created(Object sender, DataListItemEventArgs e)
  2.       {
  3.  
  4.          if (e.Item.ItemType == ListItemType.Item || 
  5.              e.Item.ItemType == ListItemType.AlternatingItem)
  6.          {
  7.  
  8.             // Retrieve the Label control in the current DataListItem.
  9.             Label PriceLabel = (Label)e.Item.FindControl("PriceLabel");
  10.  
  11.             // Retrieve the text of the CurrencyColumn from the DataListItem
  12.             // and convert the value to a Double.
  13.             Double Price = Convert.ToDouble(
  14.                 ((DataRowView)e.Item.DataItem).Row.ItemArray[2].ToString());
  15.  
  16.             // Format the value as currency and redisplay it in the DataList.
  17.             PriceLabel.Text = Price.ToString("c");
  18.  
  19.          }
Mar 15 '07 #2
Hi,

i'm already using the function

private void Item_Created(Object Sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem)
{
Button _deleteButton = (Button)e.Item.FindControl("btnDelete");
_deleteButton.Attributes.Add("onclick", "return deleteUser();");

Button _moveUserButton = (Button)e.Item.FindControl("btnMoveUser");
_moveUserButton.Attributes.Add("onclick", "return moveUser();");
}
}

this is to check for confirmation of deletion and updation with the help of javascript.. is the function that u mentioned same as this one..
Mar 15 '07 #3
kenobewan
4,871 Expert 4TB
I find that CSS usually gives the best results for these kind of things.
Mar 15 '07 #4
Hi,

Could you please tell me more on how CSS could be implemented

Thanks.
Mar 15 '07 #5
Hi,

No probs.. ive got that figured out.

Thanks.
Mar 15 '07 #6
kenobewan
4,871 Expert 4TB
Here is an example that may help:
Applying Styles to Controls
Mar 15 '07 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Tim Mulholland | last post by:
I'm writing an app in C# that requires labels to scale as the size of the window grows/shrinks. Getting the actual label itself to scale is very easy using the anchor property. But i need to get...
5
by: tshad | last post by:
How can I set the size of text in the dropdown list: <asp:DropDownList ID="ddlQuestionType" runat="server"> <asp:ListItem Value="MS" Text="Multiple Single" /> <asp:ListItem Value="MM"...
5
by: Francois Soucy | last post by:
Hi all! I've created a personal control. This control is mainly a panel with some other stuff in. I want to know if it's possible to know the size of the container of this control? I mean that my...
2
by: Dominique | last post by:
Hello, Im want to fix the width of a dashboard. I have a field which has a field (in this dashboard on the left part of my screen) which could be long and make the right side of the screen out...
6
by: Jim | last post by:
I tried to build a "form" layout without using table like this http://www.coolshare.com/temp/images/css.jpg In order to get the layout, I need to set the light blue area at each line to a fix...
0
by: benfly08 | last post by:
Hi, guys. I'm developing a web application for Sales Department people in my company. I used my 1024X768 resolution and "Medium" IE text size to test my Layout and it worked fine. However, some...
7
by: rn5a | last post by:
I am giving users the option to upload files from their hard disk to the server but only those files will be uploaded whose size is less tha or equal to 1 MB. I am using the ASP.NET FileUpload...
18
by: Diogenes | last post by:
Hi All; I, like others, have been frustrated with designing forms that look and flow the same in both IE and Firefox. They simply did not scale the same. I have discovered, to my chagrin,...
2
by: Mike Borrowdale | last post by:
-- Hi, my application simulates a panel of scientific instruments. Digital readouts are provided by label components embedded in a TableLayoutPanel with the rows and columns set to...
6
by: Miro | last post by:
Is there a way to / or a mathematical formula to see if a font size is 'too big' for a label. I have a label that is docked to 'fill' a form, and I want to resize that font based on the width...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.