Skip to main content

How to make your ASP.Net label multilin

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Multiline.aspx.cs" Inherits="Multiline" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
   <title>Untitled Page</title>
</head>
<body>
   <form id="form1" runat="server">
       <div>
           <asp:Label ID="lblMultiline" runat="Server" Text=""></asp:Label>
       </div>
   </form>
</body>
</html>

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class Multiline : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

        lblMultiline.Text = FormatText("aspdotnetcodebookaspdotnetcodebookaspdotnetcodebookaspdotnetcodebookaspdotnetcodebookaspdotnetcodebookaspdotnetcodebookaspdotnetcodebookaspdotnetcodebookaspdotnetcodebookaspdotnetcodebookaspdotnetcodebookaspdotnetcodebookaspdotnetcodebookaspdotnetcodebookaspdotnetcodebookaspdotnetcodebookaspdotnetcodebookaspdotnetcodebook");

    }
    public string FormatText(string sText)
    {

        int start = 0;
        int length = 40;
        int parts = sText.Length / length + 1;

        string strPart = "";
        while (start < sText.Length)
        {
            int charactersToGet = start + length < sText.Length ? length : sText.Length - start;
            strPart = strPart + sText.Substring(start, charactersToGet) + "</br>";
            start += length;
        }
        return strPart;

    }
}

Comments

  1. HI I want to change value <embed name="nimbb_c069e67ec7" src="http://player.nimbb.com/lang=en&guid=c069e67ec7&allowfullscreen=1" width="320"....

    in this the value of guid value is different .. will come from database

    I want to make href for every guid which is there from database .. and when i click on that i want to display video related that GUID which will set upar line(<embed .....)

    ReplyDelete

Post a Comment

Popular posts from this blog