Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
4110
Getting resized TargetElement height and width
posted

I am using the WebResizingExtender tied to a textbox inside a WebGrid, which works fine. I can edit the grid row and can resize the textbox with no problem.

When they save it and it goes back to ItemTemplate, the text is displayed in a label and the text is confined to the size of the label, which is smaller of course. What they would like, is to have it displayed in the label with the same height and width as they resized it when editing the textbox.

So my question is, how( or can I) capture the 'resized' dimensions of the textbox so I can persist them? I'm using the grid methods to do the updating, etc, no javascript. I have tried all of the event handlers for the textbox, extender, etc but I only get the design-time width and height, not the resized dimensions. Is this even possible?

 

  • 4110
    posted

    Thanks, for the quick response. That will work great!

  • 24497
    Verified Answer
    posted

    Hi,

    The TargetWidth/Height should contain latest values of size. Though, if "label" is <span>, then I do not think that you may change its size. You need <div> or similar. I tested following and it worked as you probably would expect to:

    aspx:

    <ig:WebResizingExtender ID="WebResizingExtender1" runat="server" TargetControlID="TextBox1" />
    <asp:Button ID="Button1" runat="server" Text="Button" />
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    <asp:Panel ID="Panel1" runat="server" BackColor="#FF9966"></asp:Panel>

    aspx.cs:

    protected void Page_Load(object sender, EventArgs e)
    {
     if(!this.IsPostBack)
      return;
     if(this.WebResizingExtender1.TargetWidth.Length == 0)
     {
        // use your defaults
     }
     else
     {
       this.Panel1.Width = Unit.Parse(this.WebResizingExtender1.TargetWidth);
       this.Panel1.Height = Unit.Parse(this.WebResizingExtender1.TargetHeight);
     }
    }