protected override void OnPreRender(EventArgs e)

protected override void OnPreRender(EventArgs e)

1) 加入脚本

        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            this.Page.RegisterClientScriptBlock("InsertText", this.RenderScript());
   this.Page.RegisterOnSubmitStatement("StorePostBody", "StorePostBody();");
        }


2) 设定标题
       

   protected override void OnPreRender(EventArgs e)
        {
            if(_mainTitle != null)
                _mainTitle.Text = ResourceManager.GetString(Title);

            if(_subTitle != null)
                _subTitle.Text = ResourceManager.GetString(SubTitle);

            base.OnPreRender (e);
        }

3) 设定按钮客户端事件


  protected override void OnPreRender(EventArgs e)
  {
   Submit.Attributes.Add("onclick", "return SubmitSendToFriend('" + From.ClientID + "', '" + To.ClientID + "');");
  }

4) 设定控件的状态

  protected override void OnPreRender(System.EventArgs e)
  {

    if(replyButton.Visible == false)
     ((Literal)FindControl("Sep1")).Visible = false;
    

    if(threadSubButton.Visible == false)
     ((Literal)FindControl("Sep3")).Visible = false;

    if(rateButton.Visible == false)
     ((Literal)FindControl("Sep2")).Visible = false;

   base.OnPreRender (e);

  }

5) 加入脚本块

  protected override void OnPreRender(EventArgs e)
  {
   base.OnPreRender (e);
   StringBuilder sb = new StringBuilder();
   sb.Append(" ");
   sb.Append("  function ToggleRateMenu() {");
   sb.Append("    rateMenu = document.getElementById('RateMenu');");
   sb.Append("    rateButton = document.getElementById('RateButton');");
   sb.Append("");
   sb.Append("    rateMenu.style.left = getposOffset(rateButton, /"left/");");
   sb.Append("    rateMenu.style.top = getposOffset(rateButton, /"top/") + rateButton.offsetHeight;");
   sb.Append("");
   sb.Append("    if (rateMenu.style.visibility == /"hidden/") {");
   sb.Append("      rateMenu.style.visibility = /"visible/";");
   sb.Append("      rateMenu.style.display = 'block';");
   sb.Append("    } else {");
   sb.Append("      rateMenu.style.visibility = /"hidden/";");
   sb.Append("      rateMenu.style.display = 'none';");
   sb.Append("    }");
   sb.Append("  }");
   sb.Append("  ");
   sb.Append("  function getposOffset(what, offsettype){");
   sb.Append("  var totaloffset=(offsettype==/"left/")? what.offsetLeft : what.offsetTop;");
   sb.Append("  var parentEl=what.offsetParent;");
   sb.Append("  while (parentEl!=null){");
   sb.Append("    totaloffset=(offsettype==/"left/")? totaloffset+parentEl.offsetLeft : totaloffset+parentEl.offsetTop;");
   sb.Append("    parentEl=parentEl.offsetParent;");
   sb.Append("  }");
   sb.Append("  return totaloffset;");
   sb.Append("}");
   sb.Append(" ");
   Page.RegisterClientScriptBlock("RatePost",sb.ToString());
  }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值