up上去,asp.net里可不可以动态改变控件的位置??

解决方案 »

  1.   


    我是这写的一个显示Flash的控件,只要在Render函数中取得一下this.Attributes["Style"]}再附值就可以了。protected override void Render(HtmlTextWriter output)
    {
    string outputstring =@"<table id=""{7}"" style=""{8}""><tr><td>
    <object classid=""clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"" 
    codebase=""http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0""
     width={0} height={1}>
    <param name=""movie"" value={2}>
    <param name=""quality"" value=""high"">
    <embed src={3} quality=""high"" pluginspage=""http://www.macromedia.com/go/getflashplayer"" 
    type=""application/x-shockwave-flash"" width={4} height={5}></embed>
    </object></td></tr></table>";
    //调整输出函数
    outputstring=string.Format(outputstring,
    new object[]{this.Width,this.Height,
    this.ImgUrl,this.ImgUrl,this.Width,
    this.Height,this.Width,this.ID,this.Attributes["Style"]});
    output.Write(outputstring);
    }
      

  2.   

    今天解决了这个问题:
    HtmlTextWriter类有HtmlTextWriterStyle来控制具体的屏幕显示位置,类似control panel, DIV, Span等来作为contrainer帮助定位。使用div来控制位置是其中一种解决方法。看下面的例子:    protected override void Render(HtmlTextWriter output)    {        // get the styles that we want to apply to the div tag        output.AddStyleAttribute("LEFT",this.Style["LEFT"]);        output.AddStyleAttribute("TOP",this.Style["TOP"]);        output.AddStyleAttribute("POSITION", this.Style["POSITION"]);         // remove the styles we have already applied        this.Style.Remove("LEFT");        this.Style.Remove("TOP");        this.Style.Remove("POSITION");         // draw our control        output.RenderBeginTag("div");       ……        output.WriteLine("
    ");        base.Render(output);        output.RenderEndTag();    }
      

  3.   

    放到<div id=mydiv style=""></div>用Style属性去定位