?
Solved

changing width of a user control with c#

Posted on 2005-03-31
4
Medium Priority
?
212 Views
Last Modified: 2010-04-07
I have a drop down user control, I am trying to resize it from the page that contians the user control, I am not getting errors, and if I set and check the width of the user control from teh containing page with:

                  drpdwnAddressState.setDrpDwnWidth(500);
                  msg.Text = Convert.ToString(drpdwnAddressState.drpDwnWidth);

I am getting 500px as the return value, but yet the control does not actually resize. The method I am calling form the user control is:

            public void setDrpDwnWidth(int intWidth)
            {
                  DrpDwnStates.Width = intWidth;
            }

What am I missing?
0
Comment
Question by:cbittner
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Expert Comment

by:thrill_house
ID: 13672038
I assume the method is in the user control, in which case you need to change it to this.

public void setDrpDwnWidth(int intWidth)
          {
               this.Width = intWidth;
          }
0
 
LVL 9

Expert Comment

by:zaghaghi
ID: 13672570
you must use this code:

DrpDwnStates.Width  = unit.point(10);
or
DrpDwnStates.Width = unit.Percentage(20);
or
DrpDwnStates.Width  = unit.Pixel(20);
0
 
LVL 35

Expert Comment

by:YZlat
ID: 13673001
create a property for a control and then set it from the code on your main page:


protected Width _width;
public Width ControlWidth
{

get
{
return _width;
}
set
{
_width = value;
}

}

setting your property:

private void Page_Load(object sender, System.EventArgs e)
{
   // Put user code to initialize the page here
   myControl.ControlWidth = "500px";
}
0
 
LVL 35

Accepted Solution

by:
YZlat earned 500 total points
ID: 13673032
I'm sorry, it should be:

protected String _width;
public String ControlWidth
{

get
{
return _width;
}
set
{
_width = value;
}

}

setting your property:

private void Page_Load(object sender, System.EventArgs e)
{
   // Put user code to initialize the page here
   myControl.ControlWidth = "500px";
}
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lots of people ask this question on how to extend the “MembershipProvider” to make use of custom authentication like using existing database or make use of some other way of authentication. Many blogs show you how to extend the membership provider c…
This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses
Course of the Month11 days, 5 hours left to enroll

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question