locked
Link button text wrapping RRS feed

  • Question

  • I had created a linkbutton and binding with a column of a data table .I want that if the no of character size of that text is greater than 10 the it will wrap it and there will be one picture on which if we click it shows all the character of that text..How can I do this?Please help me...
    Monday, September 3, 2012 6:25 AM

Answers

  • Hi Shubho_Simple,

    I’m not sure whether you can use logic like this in LinkButton to check the text character size number, you may consider new the button object right inside the text size check logic, if the size less than 10, generate a linkbutton with text, if it is greater than 10, generate a button with image and text, to show the text when clicking the button, you can try to use JavaScript code:
    <asp:LinkButton ID="lbYear" OnClientClick="hideImage(); return true;" runat="server" CausesValidation="false" >

    <asp:Image ID="imgFolder" runat="server" ImageUrl="~/_layouts/images/picture1.jif"/>

    </asp:LinkButton>

    <script type="text/javascript">

        function hideImage () {

            var img = document.getElementById("ctl00_PlaceHolderMain_imgFolder");

            img.style.display = "none";

            var btn = document.getElementById("ctl00_PlaceHolderMain_lbYear");

            btn.innerText = "LinkedButton";

       }

    </script>

    Also, for this issue, people in C# forum will be more professional about this, it would be better to go to that forum for more information:
    Visual C#:
    http://social.msdn.microsoft.com/Forums/en-US/category/visualcsharp

    Thanks,


    Qiao Wei

    TechNet Community Support

    • Proposed as answer by Arup Biswas Tuesday, September 4, 2012 7:48 AM
    • Marked as answer by Lhan Han Friday, September 14, 2012 12:04 PM
    Tuesday, September 4, 2012 6:11 AM
  • Hi Shubho,

    You can use IE Developer Tool to get the auto-generated control id, here is an article about how to use IE Developer Tool(IE8+):
    http://msdn.microsoft.com/en-us/library/ie/gg589512(v=vs.85).aspx


    Thanks,
    Lhan Han

    • Marked as answer by Lhan Han Friday, September 14, 2012 12:04 PM
    Friday, September 14, 2012 12:04 PM

All replies

  • Hi Shubho_Simple,

    I’m not sure whether you can use logic like this in LinkButton to check the text character size number, you may consider new the button object right inside the text size check logic, if the size less than 10, generate a linkbutton with text, if it is greater than 10, generate a button with image and text, to show the text when clicking the button, you can try to use JavaScript code:
    <asp:LinkButton ID="lbYear" OnClientClick="hideImage(); return true;" runat="server" CausesValidation="false" >

    <asp:Image ID="imgFolder" runat="server" ImageUrl="~/_layouts/images/picture1.jif"/>

    </asp:LinkButton>

    <script type="text/javascript">

        function hideImage () {

            var img = document.getElementById("ctl00_PlaceHolderMain_imgFolder");

            img.style.display = "none";

            var btn = document.getElementById("ctl00_PlaceHolderMain_lbYear");

            btn.innerText = "LinkedButton";

       }

    </script>

    Also, for this issue, people in C# forum will be more professional about this, it would be better to go to that forum for more information:
    Visual C#:
    http://social.msdn.microsoft.com/Forums/en-US/category/visualcsharp

    Thanks,


    Qiao Wei

    TechNet Community Support

    • Proposed as answer by Arup Biswas Tuesday, September 4, 2012 7:48 AM
    • Marked as answer by Lhan Han Friday, September 14, 2012 12:04 PM
    Tuesday, September 4, 2012 6:11 AM
  • ctl00_PlaceHolderMain_imgFolder" How would u get this id?
    Thursday, September 6, 2012 9:20 AM
  • Hi Shubho,

    You can use IE Developer Tool to get the auto-generated control id, here is an article about how to use IE Developer Tool(IE8+):
    http://msdn.microsoft.com/en-us/library/ie/gg589512(v=vs.85).aspx


    Thanks,
    Lhan Han

    • Marked as answer by Lhan Han Friday, September 14, 2012 12:04 PM
    Friday, September 14, 2012 12:04 PM