Click here to Skip to main content
15,902,299 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
1.I'm having a textbox in Usercontrol

ASP.NET
<uc1:MultipleSelectionCtrl ID="ContractingOfficeLocationCtrl"  runat="server" Visible="false" />

2.Control pages having the Property of textbox a Unit

VB
Public Property TextBoxWidth() As Unit
        Get
            Return txtSelection.Width
        End Get
        Set(ByVal value As Unit)
            txtSelection.Width = value
        End Set
End Property


3.Now i want to give the width of textbox in percentage from Codebehind

Help me.......
Posted
Updated 15-Dec-13 23:53pm
v3
Comments
Maciej Los 16-Dec-13 5:06am    
What have you done till now? Where are you stuck?
Boothalingam 16-Dec-13 5:08am    
Separate Control: <uc1:MultipleSelectionCtrl ID="FundingOfficeCtrl" runat="server" />
Setting width From Codebehind:

Public Property TextBoxWidth() As Unit
Get
Return txtSelection.Width
End Get
Set(ByVal value As Unit)
txtSelection.Width = value
'Dim Width As Double = Convert.ToDouble(value)
'txtSelection.Width = Unit.Percentage(Width)
End Set
End Property
Maciej Los 16-Dec-13 5:27am    
Please, use "Improve question" widget instead posting code in comment.

1 solution

First of all, i would recommend you to read this: Walkthrough: Creating a Web Custom Control[^]

Secondly, to change Width of control using percentage value, you need to calculate it. For example, when you pass 50 as a input parameter (pw),
VB
textbox1.Width = textbox1.Width * pw / 100
'we need to divide pw per 100, because 50% = 0.5
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900