/// <summary> /// Maps a text box to a default button when the enter key is pressed. Registers a /// small client script block in JavaScript to allow the functionality. /// </summary> /// <param name="page">The page the control resides in.</param> /// <param name="defaultButton">The button to associate the text box to.</param> /// <param name="textBoxArray">The array of text box controls to associate the button to.</param> public static void MapDefaultButton(System.Web.UI.WebControls.Button defaultButton, params System.Web.UI.WebControls.WebControl[] controls) { string sScript = "\n<SCRIPT language=\"javascript\">\n" + "function fnTrapKD(btn){\n" + " if (document.all){\n" + " if (event.keyCode == 13)\n" + "{ \n" + " event.returnValue=false;\n" + " event.cancel = true;\n" + " btn.click();\n" + " }\n" + " }\n" + "}\n" + "</SCRIPT>\n"; foreach (System.Web.UI.WebControls.WebControl control in controls) { control.Attributes.Add("onkeydown", "fnTrapKD(document.all." + defaultButton.ClientID + ")"); if (!control.Page.ClientScript.IsClientScriptBlockRegistered("ForceDefaultToScript")) { control.Page.ClientScript.RegisterClientScriptBlock(typeof(ControlExtender), "ForceDefaultToScript", sScript); } } }
//当用户点击按钮时,将其置为无效 public void DisableSubmitBotton(Page mypage, System.Web.UI.WebControls.Button submitbutton) { RegisterAdminPageClientScriptBlock(); //保证 __doPostBack(eventTarget, eventArgument) 正确注册 #if NET1 mypage.GetPostBackEventReference(submitbutton, ""); #else mypage.ClientScript.GetPostBackEventReference(submitbutton, ""); #endif StringBuilder sb = new StringBuilder(); //保证验证函数的执行 sb.Append("if (typeof(Page_ClientValidate) == 'function') { if (Page_ClientValidate() == false) { return false; }}"); // disable所有submit按钮 sb.Append("disableOtherSubmit();"); //sb.Append("document.getElementById('Layer5').innerHTML ='正在运行操作</td></tr></table><BR />';"); sb.Append("document.getElementById('success').style.display ='block';"); #if NET1 //用__doPostBack来提交,保证按钮的服务器端click事件执行 sb.Append(this.GetPostBackEventReference(submitbutton, "")); #else sb.Append(this.ClientScript.GetPostBackEventReference(submitbutton, "")); #endif sb.Append(";"); submitbutton.Attributes.Add("onclick", sb.ToString()); }
/// <summary> /// /// </summary> /// <param name="_Button"></param> /// <param name="S"></param> /// <returns></returns> private System.Web.UI.WebControls.Button ImageButton(System.Web.UI.WebControls.Button _Button, int S) { if (_ButtonImageAttributes.Count != 0) { string outString = _ButtonImageAttributes[S - 1].ToString(); string[] outStringArr = outString.Split(new char[] { '|' }); if (S != 5) { _Button.Text = ""; } _Button.BorderWidth = new System.Web.UI.WebControls.Unit(0); _Button.Attributes.CssStyle.Add("border", "none"); _Button.Attributes.CssStyle.Add("background", "url(" + outStringArr[0].ToString() + ")"); _Button.Attributes.CssStyle.Add("background-repeat", "no-repeat"); _Button.Attributes.CssStyle.Add("width", outStringArr[1].ToString()); _Button.Attributes.CssStyle.Add("height", outStringArr[2].ToString()); if (_ButtonImageByMouseChange) { _Button.Attributes.Add("onmouseover", "this.style.backgroundPosition='bottom';"); _Button.Attributes.Add("onmouseout", "this.style.backgroundPosition='top';"); } } else { _Button.Attributes.Add("onmouseover", "this.style.background='" + _ButtonNowColor + "';"); _Button.Attributes.Add("onmouseout", "this.style.background='" + _ButtonColor + "';"); } return(_Button); }
/// <summary> /// Add the confirm message to button /// 代码调用: /// UIHelper.AddConfirm(this.Button1, "真的要删了?"); /// 点确定按钮就会执行事件中的代码,点取消不? /// </summary> /// <param name="button">The control, must be a button</param> /// <param name="strMsg">The popup message</param> public static void AddConfirm(System.Web.UI.WebControls.Button button, string strMsg) { strMsg = strMsg.Replace("\n", "file://n/"); strMsg = strMsg.Replace("\r", "file://r/"); strMsg = strMsg.Replace("\"", "\\\""); strMsg = strMsg.Replace("\'", "\\\'"); button.Attributes.Add("onClick", "return confirm('" + strMsg + "')"); }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Num_Button_Click(object sender, EventArgs e) { System.Web.UI.WebControls.Button _Button = (System.Web.UI.WebControls.Button)sender; int Num = int.Parse(_Button.ID.ToString().Replace("M_Num" + _SessionString, "")); ((System.Web.UI.WebControls.HiddenField)_Button.Parent.FindControl(_SessionString)).Value = Convert.ToString(Num); DoPage(_Button.Page, __DS, __Repeater); }
/// <summary> /// Button控件翻译,从数据库中取值 /// </summary> /// <param name="button">要翻译的服务器控件</param> /// <param name="keyCode">字典键值</param> /// <param name="defaultText">默认值</param> public static void TranslationButtonDB(System.Web.UI.WebControls.Button button, string keyCode, string defaultText) { string tlText = string.Empty; tlText = Translate(keyCode); if (tlText == "") { tlText = defaultText; } button.Text = tlText; }
/// <summary> /// /// </summary> /// <param name="_Button"></param> /// <param name="Num"></param> private System.Web.UI.WebControls.Button NowNumIndex(System.Web.UI.WebControls.Button _Button, int Num) { if ((_PageIndex - 1) == Num) { _Button.Enabled = false; _Button.ToolTip = "当前页"; _Button.BackColor = System.Drawing.Color.FromName(_ButtonNowColor); _Button.Attributes.CssStyle.Add("font-weight", "700"); } return(_Button); }
public static void RegisterDisableOnSubmitAttribute(System.Web.UI.WebControls.Button button) { // string functionName = "DisableButtonOnSubmit_onclick"; string script = "if (typeof(Page_ClientValidate) == 'function') { " + "if (Page_ClientValidate() == false) { return false; }} " + "this.value = 'Please wait...';" + "this.disabled = true;" + button.Page.ClientScript.GetPostBackEventReference(button, string.Empty) + ";"; button.Attributes.Add("onclick", script); }
/// <summary> /// /// </summary> private void CreatePrevButton() { System.Web.UI.WebControls.Button _Button = CreateButton(); _Button.ID = "PrevButton" + _SessionString; _Button.Text = "<"; _Button.ToolTip = "上一页"; _Button = ImageButton(_Button, 2); if (_PageIndex == 1) { _Button.Enabled = false; _Button.ToolTip = "已是第一页"; } _Button.Click += new EventHandler(_Button_Click2); __HtmlGenericControl.Controls.Add(_Button); }
/// <summary> /// /// </summary> private void CreateLastButton() { System.Web.UI.WebControls.Button _Button = CreateButton(); _Button.ID = "LastButton" + _SessionString; _Button.Text = ">>|"; _Button.ToolTip = "末页"; _Button = ImageButton(_Button, 4); if (_PageIndex == _PageCount) { _Button.Enabled = false; _Button.ToolTip = "已是最后一页"; } _Button.Click += new EventHandler(_Button_Click4); __HtmlGenericControl.Controls.Add(_Button); }
/// <summary> /// 让服务器按钮点击后变灰 /// </summary> /// <param name="button"></param> /// <param name="newText">点后的显示文本</param> public static void ClickDisabled(this System.Web.UI.WebControls.Button button, string newText = "") { if (button == null) { return; } StringBuilder js = new StringBuilder(); System.Web.UI.Page page = (System.Web.UI.Page)HttpContext.Current.Handler; page.ClientScript.GetPostBackEventReference(button, string.Empty); if (!button.ValidationGroup.IsNullOrEmpty()) { js.AppendFormat("if({0})", button.ValidationGroup); js.Append("{"); if (!button.OnClientClick.IsNullOrEmpty()) { js.Append(button.OnClientClick); } js.Append("this.disabled=true;"); if (!newText.IsNullOrEmpty()) { js.AppendFormat("this.value=\"{0}\";", newText); } js.AppendFormat("__doPostBack(\"{0}\",\"\");", button.ID); js.Append("}else{return false;}"); } else { if (!button.OnClientClick.IsNullOrEmpty()) { js.Append(button.OnClientClick); } js.Append("this.disabled=true;"); if (!newText.IsNullOrEmpty()) { js.AppendFormat("this.value=\"{0}\";", newText); } js.AppendFormat("__doPostBack(\"{0}\",\"\");", button.ID); } button.OnClientClick = js.ToString(); }
protected override void AttachChildControls() { this.txtUserName = (System.Web.UI.WebControls.TextBox) this.FindControl("txtUserName"); this.txtEmail = (System.Web.UI.WebControls.TextBox) this.FindControl("txtEmail"); this.txtPassword = (System.Web.UI.WebControls.TextBox) this.FindControl("txtPassword"); this.txtPasswordCompare = (System.Web.UI.WebControls.TextBox) this.FindControl("txtPasswordCompare"); this.txtTransactionPassword = (System.Web.UI.WebControls.TextBox) this.FindControl("txtTransactionPassword"); this.txtTransactionPasswordCompare = (System.Web.UI.WebControls.TextBox) this.FindControl("txtTransactionPasswordCompare"); this.txtRealName = (System.Web.UI.WebControls.TextBox) this.FindControl("txtRealName"); this.txtCompanyName = (System.Web.UI.WebControls.TextBox) this.FindControl("txtCompanyName"); this.dropRegion = (RegionSelector)this.FindControl("dropRegion"); this.txtAddress = (System.Web.UI.WebControls.TextBox) this.FindControl("txtAddress"); this.txtZipcode = (System.Web.UI.WebControls.TextBox) this.FindControl("txtZipcode"); this.txtQQ = (System.Web.UI.WebControls.TextBox) this.FindControl("txtQQ"); this.txtWangwang = (System.Web.UI.WebControls.TextBox) this.FindControl("txtWangwang"); this.txtMSN = (System.Web.UI.WebControls.TextBox) this.FindControl("txtMSN"); this.txtTelPhone = (System.Web.UI.WebControls.TextBox) this.FindControl("txtTelPhone"); this.txtCellPhone = (System.Web.UI.WebControls.TextBox) this.FindControl("txtCellPhone"); this.txtPasswordQuestion = (System.Web.UI.WebControls.TextBox) this.FindControl("txtPasswordQuestion"); this.txtPasswordAnswer = (System.Web.UI.WebControls.TextBox) this.FindControl("txtPasswordAnswer"); this.btnOK = (System.Web.UI.WebControls.Button) this.FindControl("btnOK"); this.btnOK.Click += new System.EventHandler(this.btnOK_Click); }
/// <summary> /// /// </summary> /// <returns></returns> private System.Web.UI.WebControls.Button CreateButton() { System.Web.UI.WebControls.Button _Button = new System.Web.UI.WebControls.Button(); if (!_ButtonColor.Equals(String.Empty)) { try { _Button.BackColor = System.Drawing.Color.FromName(_ButtonColor); } catch { throw new Exception("颜色值不正确"); } } _Button.BorderWidth = new System.Web.UI.WebControls.Unit(1); _Button.BorderStyle = System.Web.UI.WebControls.BorderStyle.Solid; _Button.BorderColor = System.Drawing.Color.FromName(_ButtonBorderColor); _Button.Attributes.CssStyle.Add("margin-right", _ButtonMargin); _Button.Attributes.CssStyle.Add("color", _ButtonFontColor); _Button.Width = new System.Web.UI.WebControls.Unit(42); return(_Button); }
protected override void CreateChildControls() { inputGroup = new System.Web.UI.HtmlControls.HtmlGenericControl("div"); inputGroup.Attributes.Add("class", "input-group"); Controls.Add(inputGroup); ctrl = new System.Web.UI.HtmlControls.HtmlInputText(); ctrl.ID = "ctrl"; ctrl.Attributes.Add("class", "form-control"); ctrl.Attributes.Add("disabled", "disabled"); inputGroup.Controls.Add(ctrl); inputGroupButton = new System.Web.UI.HtmlControls.HtmlGenericControl(); inputGroupButton.Attributes.Add("class", "input-group-btn"); inputGroup.Controls.Add(inputGroupButton); PickerButton = new System.Web.UI.HtmlControls.HtmlButton(); PickerButton.ID = "PickerButton"; PickerButton.Attributes.Add("class", "btn btn-default"); PickerButton.InnerText = "..."; inputGroupButton.Controls.Add(PickerButton); ResetButton = new System.Web.UI.WebControls.Button(); ResetButton.ID = "ResetButton"; ResetButton.Attributes.Add("class", "btn btn-default"); ResetButton.Text = "Reset"; inputGroupButton.Controls.Add(ResetButton); ctrlvalue = new System.Web.UI.HtmlControls.HtmlInputHidden(); ctrlvalue.ID = "ctrlvalue"; ctrlvalue.Name = "ctrlvalue"; inputGroup.Controls.Add(ctrlvalue); }
/// <summary> /// Displays a <see cref="MessageBox"/> but as a TopMost window. /// </summary> /// <param name="message">The text to appear in the message box.</param> /// <param name="title">The title of the message box.</param> /// <returns>The button pressed.</returns> /// <remarks>This will display with no title and only the OK button.</remarks> /// public static void MsgConfirmBox(System.Web.UI.WebControls.Button btn, string strMessage) { strMessage = strMessage.Replace("'", "\\'"); btn.Attributes.Add("onclick", "return confirm('" + strMessage + "');"); }
public static void DefaultButton(System.Web.UI.Page Page, ref System.Web.UI.WebControls.TextBox objTextControl, ref System.Web.UI.WebControls.Button objDefaultButton) { try { System.Text.StringBuilder sScript = new System.Text.StringBuilder(); sScript.Append(Environment.NewLine + "<SCRIPT language=\"javascript\">" + Environment.NewLine); sScript.Append("function fnTrapKD(btn) {" + Environment.NewLine); sScript.Append(" if (document.all){" + Environment.NewLine); sScript.Append(" if (event.keyCode == 13)" + Environment.NewLine); sScript.Append(" { " + Environment.NewLine); sScript.Append(" event.returnValue=false;" + Environment.NewLine); sScript.Append(" event.cancel = true;" + Environment.NewLine); sScript.Append(" btn.click();" + Environment.NewLine); sScript.Append(" } " + Environment.NewLine); sScript.Append(" } " + Environment.NewLine); sScript.Append("}" + Environment.NewLine); sScript.Append("</SCRIPT>" + Environment.NewLine); objTextControl.Attributes.Add("onkeydown", "try { fnTrapKD(document.all." + objDefaultButton.ClientID + "); } catch (e) {}"); //Page.RegisterStartupScript("ForceDefaultToScript", sScript.ToString()); Page.ClientScript.RegisterStartupScript(Page.GetType(), "ForceDefaultToScript", sScript.ToString()); } catch (System.Exception ex) { UIManager.AdministrationManager.DiagnosticError(ex); } }
/// <summary> /// /// </summary> /// <param name="pageindex"></param> /// <param name="pagecount"></param> /// <param name="sumNum"></param> private void CreateShuju(string pageindex, string pagecount, string sumNum) { if (int.Parse(pagecount) > 10) { if ((_PageIndex > 5) && (_PageIndex < (_PageCount - 5))) { //1,2页 for (int s = 0; s < 2; s++) { System.Web.UI.WebControls.Button _Button = CreateButton(); _Button.ID = "M_Num" + _SessionString + s.ToString(); _Button.Text = Convert.ToString(s + 1); _Button.ToolTip = "第" + Convert.ToString(s + 1) + "页"; _Button = ImageButton(_Button, 5); _Button.Click += new EventHandler(Num_Button_Click); _Button = NowNumIndex(_Button, s); __HtmlGenericControl.Controls.Add(_Button); } System.Web.UI.WebControls.Label _Label1 = new System.Web.UI.WebControls.Label(); _Label1.ID = "M_SSS" + _SessionString; _Label1.Text = "…"; __HtmlGenericControl.Controls.Add(_Label1); for (int s = 1; s <= 3; s++) { System.Web.UI.WebControls.Button _Button = CreateButton(); _Button.ID = "M_Num" + _SessionString + Convert.ToString(_PageIndex - 4 + s - 1); _Button.Text = Convert.ToString(_PageIndex - 4 + s); _Button.ToolTip = "第" + Convert.ToString(_PageIndex - 4 + s) + "页"; _Button = ImageButton(_Button, 5); _Button.Click += new EventHandler(Num_Button_Click); _Button = NowNumIndex(_Button, _PageIndex - 4 + s - 1); __HtmlGenericControl.Controls.Add(_Button); } System.Web.UI.WebControls.Button _ButtonNow = CreateButton(); _ButtonNow.ID = "M_Num" + _SessionString + Convert.ToString(_PageIndex - 1); _ButtonNow.Text = Convert.ToString(_PageIndex); _ButtonNow.ToolTip = "第" + Convert.ToString(_PageIndex) + "页"; _ButtonNow = ImageButton(_ButtonNow, 5); _ButtonNow.Click += new EventHandler(Num_Button_Click); _ButtonNow = NowNumIndex(_ButtonNow, _PageIndex - 1); __HtmlGenericControl.Controls.Add(_ButtonNow); for (int s = 1; s <= 3; s++) { System.Web.UI.WebControls.Button _Button = CreateButton(); _Button.ID = "M_Num" + _SessionString + Convert.ToString(_PageIndex + s - 1); _Button.Text = Convert.ToString(_PageIndex + s); _Button.ToolTip = "第" + Convert.ToString(_PageIndex + s) + "页"; _Button = ImageButton(_Button, 5); _Button.Click += new EventHandler(Num_Button_Click); _Button = NowNumIndex(_Button, _PageIndex + s - 1); __HtmlGenericControl.Controls.Add(_Button); } System.Web.UI.WebControls.Label _Label2 = new System.Web.UI.WebControls.Label(); _Label2.ID = "M_ZZZ" + _SessionString; _Label2.Text = _ButtonIco; __HtmlGenericControl.Controls.Add(_Label2); //后两页 for (int u = int.Parse(pagecount) - 2; u < int.Parse(pagecount); u++) { System.Web.UI.WebControls.Button _Button = CreateButton(); _Button.ID = "M_Num" + _SessionString + u.ToString(); _Button.Text = Convert.ToString(u + 1); _Button.ToolTip = "第" + Convert.ToString(u + 1) + "页"; _Button = ImageButton(_Button, 5); _Button.Click += new EventHandler(Num_Button_Click); _Button = NowNumIndex(_Button, u); __HtmlGenericControl.Controls.Add(_Button); } } else if ((_PageIndex <= 5) && (_PageIndex < (_PageCount - 5))) { for (int s = 1; s <= 7; s++) { System.Web.UI.WebControls.Button _Button = CreateButton(); _Button.ID = "M_Num" + _SessionString + Convert.ToString(s - 1); _Button.Text = s.ToString(); _Button.ToolTip = "第" + s.ToString() + "页"; _Button = ImageButton(_Button, 5); _Button.Click += new EventHandler(Num_Button_Click); _Button = NowNumIndex(_Button, s - 1); __HtmlGenericControl.Controls.Add(_Button); } System.Web.UI.WebControls.Label _Label2 = new System.Web.UI.WebControls.Label(); _Label2.ID = "M_ZZZ" + _SessionString; _Label2.Text = _ButtonIco; __HtmlGenericControl.Controls.Add(_Label2); //后两页 for (int u = int.Parse(pagecount) - 2; u < int.Parse(pagecount); u++) { System.Web.UI.WebControls.Button _Button = CreateButton(); _Button.ID = "M_Num" + _SessionString + u.ToString(); _Button.Text = Convert.ToString(u + 1); _Button.ToolTip = "第" + Convert.ToString(u + 1) + "页"; _Button = ImageButton(_Button, 5); _Button.Click += new EventHandler(Num_Button_Click); _Button = NowNumIndex(_Button, u); __HtmlGenericControl.Controls.Add(_Button); } } else if ((_PageIndex > 5) && (_PageIndex >= (_PageCount - 5))) { //1,2页 for (int s = 0; s < 2; s++) { System.Web.UI.WebControls.Button _Button = CreateButton(); _Button.ID = "M_Num" + _SessionString + s.ToString(); _Button.Text = Convert.ToString(s + 1); _Button.ToolTip = "第" + Convert.ToString(s + 1) + "页"; _Button = ImageButton(_Button, 5); _Button.Click += new EventHandler(Num_Button_Click); _Button = NowNumIndex(_Button, s); __HtmlGenericControl.Controls.Add(_Button); } System.Web.UI.WebControls.Label _Label1 = new System.Web.UI.WebControls.Label(); _Label1.ID = "M_SSS" + _SessionString; _Label1.Text = _ButtonIco; __HtmlGenericControl.Controls.Add(_Label1); for (int s = 1; s <= 7; s++) { System.Web.UI.WebControls.Button _Button = CreateButton(); _Button.ID = "M_Num" + _SessionString + Convert.ToString(_PageCount - 7 + s - 1); _Button.Text = Convert.ToString(_PageCount - 7 + s); _Button.ToolTip = "第" + Convert.ToString(_PageCount - 7 + s) + "页"; _Button = ImageButton(_Button, 5); _Button.Click += new EventHandler(Num_Button_Click); _Button = NowNumIndex(_Button, _PageCount - 7 + s - 1); __HtmlGenericControl.Controls.Add(_Button); } } } else { for (int i = 0; i < int.Parse(pagecount); i++) { System.Web.UI.WebControls.Button _Button = CreateButton(); _Button.ID = "M_Num" + _SessionString + i.ToString(); _Button.Text = Convert.ToString(i + 1); _Button.ToolTip = "第" + Convert.ToString(i + 1) + "页"; _Button = ImageButton(_Button, 5); _Button.Click += new EventHandler(Num_Button_Click); _Button = NowNumIndex(_Button, i); __HtmlGenericControl.Controls.Add(_Button); } } }
/// <summary> /// /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void _Button_Click4(object sender, EventArgs e) { System.Web.UI.WebControls.Button _Button = (System.Web.UI.WebControls.Button)sender; ((System.Web.UI.WebControls.HiddenField)_Button.Parent.FindControl(_SessionString)).Value = Convert.ToString(_PageCount - 1); DoPage(_Button.Page, __DS, __Repeater); }
private void CreateControls() { if (Question == null) { Label noPollAvailableLabel = new Label(); noPollAvailableLabel.Text = "No poll available"; this.Controls.Add(new LiteralControl("<i>")); this.Controls.Add(noPollAvailableLabel); this.Controls.Add(new LiteralControl("</i>")); } else { } //Hyperlink HyperLink hyp = new HyperLink(); hyp.NavigateUrl = "~/portal/evaluation/poll/List.aspx"; hyp.Text = "All polls"; this.Controls.Add(hyp); this.Controls.Add(new LiteralControl("<br/>")); this.Controls.Add(new LiteralControl("<br/>")); //Question Label questionLabel = new Label(); questionLabel.Text = Question.Question; questionLabel.Style.Add(HtmlTextWriterStyle.FontWeight, "bold"); this.Controls.Add(questionLabel); this.Controls.Add(new LiteralControl("<br/>")); //Me.Controls.Add(New LiteralControl("<ul>")) if (IsUserAllowedToVote) { RadioButtonList rbl = new RadioButtonList(); //The LinkButton Answers foreach (PollAnswers answer in AnswerTable) { rbl.Items.Add(new ListItem(answer.Answer, answer.PollAnswerId.ToString())); } this.Controls.Add(rbl); this.Controls.Add(new LiteralControl("<br />")); //only render the SubmitButton when there are answers if (AnswerTable.Count > 0) { System.Web.UI.WebControls.Button rlb = new System.Web.UI.WebControls.Button(); rlb.Text = "Submit"; rlb.Click += new System.EventHandler(SubmitButton_Click); this.Controls.Add(rlb); } this.Controls.Add(new LiteralControl("<br />")); } else { this.Controls.Add(new LiteralControl("<ul>")); //The Label answers foreach (PollAnswers row in AnswerTable) { decimal percentage = ComputePercentage(Poll.NumberOfVotesByAnswer(row.PollAnswerId)); this.Controls.Add(new LiteralControl("<li>")); Label answerLabel = new Label(); answerLabel.Text = string.Format("{0}:", row.Answer); this.Controls.Add(answerLabel); this.Controls.Add(new LiteralControl("<br/>")); System.Web.UI.WebControls.Image img = new System.Web.UI.WebControls.Image(); img.ImageUrl = "~/images/pixel.png"; img.Height = new Unit(7); img.Width = new Unit(percentage.ToString()); this.Controls.Add(img); Label percentageLabel = new Label(); percentageLabel.Text = string.Format(" ({0}%)", percentage.ToString()); this.Controls.Add(percentageLabel); this.Controls.Add(new LiteralControl("</li>")); } this.Controls.Add(new LiteralControl("</ul>")); //The summary HyperLink summaryLink = new HyperLink(); string ttlvotes = Poll.CountTotalVotes(Question.PollId).ToString(); if (ttlvotes == "1") { summaryLink.Text = string.Format("{0} vote", ttlvotes); } else { summaryLink.Text = string.Format("{0} votes", ttlvotes); } summaryLink.NavigateUrl = "~/portal/evaluation/poll/View.aspx?PollId=" + Question.PollId.ToString(); this.Controls.Add(summaryLink); this.Controls.Add(new LiteralControl("<br/>")); HyperLink totalReactionsLink = new HyperLink(); string ttlrxns = Poll.CountTotalReactions(Question.PollId).ToString(); if (ttlrxns == "1") { totalReactionsLink.Text = string.Format("{0} reactie", ttlrxns); } else { totalReactionsLink.Text = string.Format("{0} reacties", ttlrxns); } totalReactionsLink.NavigateUrl = "~/portal/evaluation/poll/View.aspx?PollId=" + Question.PollId.ToString(); this.Controls.Add(totalReactionsLink); } //Administrator section if (Page.User.IsInRole("Administrators")) { this.Controls.Add(new LiteralControl("<br/>")); this.Controls.Add(new LiteralControl("<br/>")); System.Web.UI.WebControls.Button adminLinkButton = new System.Web.UI.WebControls.Button(); adminLinkButton.PostBackUrl = "~/portal/evaluation/poll/Manage.aspx"; adminLinkButton.Text = "Manage Polls"; this.Controls.Add(adminLinkButton); } }
/// <summary> /// 弹出确认窗口,如果点击否则不执行操作 /// </summary> /// <param name="btn">绑定的按钮</param> /// <param name="Message">提示信息</param> public static void popupConfirmMessage(System.Web.UI.WebControls.Button btn, string Message) { btn.Attributes.Add("OnClick", "javascript:window.event.returnValue=window.confirm('" + Message + "');"); }
public static void HtmlForm(System.Web.UI.HtmlControls.HtmlControl htmlControl, string[] fields, int[] widths, int[] lengths, string functionSubmit = null, string[] types = null) { System.Web.UI.WebControls.Panel panel; System.Web.UI.WebControls.Label label; System.Web.UI.WebControls.TextBox textBox; System.Web.UI.WebControls.Button button; functionSubmit = functionSubmit ?? "void(0)"; if (types == null) { types = new string[fields.Length]; for (int i = 0; i < fields.Length; i++) { types[i] = "t"; } } for (int i = 0; i < fields.Length; i++) { label = new System.Web.UI.WebControls.Label { ID = "label_" + i, Text = fields[i], CssClass = "label" }; textBox = new System.Web.UI.WebControls.TextBox { ID = ("field_" + fields[i]).Replace(" ", "_").ToLower(), MaxLength = lengths[i], CssClass = "input border", TextMode = types[i].Equals("pwd") ? System.Web.UI.WebControls.TextBoxMode.Password : System.Web.UI.WebControls.TextBoxMode.SingleLine }; panel = new System.Web.UI.WebControls.Panel { ID = "panel_" + i, CssClass = "col padding-16 s12 m" + widths[i] }; panel.Controls.Add(label); panel.Controls.Add(textBox); htmlControl.Controls.Add(panel); } panel = new System.Web.UI.WebControls.Panel { ID = "panel_submit", CssClass = "col padding-16 s12" }; button = new System.Web.UI.WebControls.Button { ID = "submit_form", CssClass = "button blue hover-blue-gray", Text = "Enviar dados", OnClientClick = functionSubmit }; panel.Controls.Add(button); htmlControl.Controls.Add(panel); }
/// <summary> /// 服务器控件的翻译,从数据库中取值 /// </summary> /// <param name="control">要翻译的控件</param> /// <param name="items">二维数组型参数,第二维第一个为字典键值,第二个为默认值</param> public void TranControlsDB(object control, string[][] items) { switch (control.GetType().ToString()) // { case "System.Web.UI.WebControls.GridView": System.Web.UI.WebControls.GridView gv = (System.Web.UI.WebControls.GridView)control; Translation.TranslationGridViewDB(gv, items); break; case "System.Web.UI.WebControls.DataGrid": System.Web.UI.WebControls.DataGrid dg = (System.Web.UI.WebControls.DataGrid)control; Translation.TranslationDataGridDB(dg, items); break; case "System.Web.UI.WebControls.RadioButtonList": System.Web.UI.WebControls.RadioButtonList rbl = (System.Web.UI.WebControls.RadioButtonList)control; Translation.TranslationRadioButtonListDB(rbl, items); break; case "System.Web.UI.WebControls.DropDownList": System.Web.UI.WebControls.DropDownList ddl = (System.Web.UI.WebControls.DropDownList)control; Translation.TranslationDropDownListDB(ddl, items); break; case "System.Web.UI.WebControls.CheckBoxList": System.Web.UI.WebControls.CheckBoxList chkl = (System.Web.UI.WebControls.CheckBoxList)control; Translation.TranslationCheckBoxListDB(chkl, items); break; case "System.Web.UI.WebControls.Button": System.Web.UI.WebControls.Button button = (System.Web.UI.WebControls.Button)control; Translation.TranslationButtonDB(button, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.LinkButton": System.Web.UI.WebControls.LinkButton lbtn = (System.Web.UI.WebControls.LinkButton)control; Translation.TranslationLinkButtonDB(lbtn, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.ImageButton": System.Web.UI.WebControls.ImageButton imgBtn = (System.Web.UI.WebControls.ImageButton)control; Translation.TranslationImageButtonDB(imgBtn, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.HyperLink": System.Web.UI.WebControls.HyperLink hl = (System.Web.UI.WebControls.HyperLink)control; Translation.TranslationHyperLinkDB(hl, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.Label": System.Web.UI.WebControls.Label label = (System.Web.UI.WebControls.Label)control; Translation.TranslationLabelDB(label, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.CheckBox": System.Web.UI.WebControls.CheckBox chk = (System.Web.UI.WebControls.CheckBox)control; Translation.TranslationCheckBoxDB(chk, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.RadioButton": System.Web.UI.WebControls.RadioButton rbtn = (System.Web.UI.WebControls.RadioButton)control; Translation.TranslationRadioButtonDB(rbtn, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.RequiredFieldValidator": System.Web.UI.WebControls.RequiredFieldValidator rfv = (System.Web.UI.WebControls.RequiredFieldValidator)control; Translation.TranslationRequiredFieldValidatorDB(rfv, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.RangeValidator": System.Web.UI.WebControls.RangeValidator rv = (System.Web.UI.WebControls.RangeValidator)control; Translation.TranslationRangeValidatorDB(rv, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.CompareValidator": System.Web.UI.WebControls.CompareValidator cv = (System.Web.UI.WebControls.CompareValidator)control; Translation.TranslationCompareValidatorDB(cv, items[0][0], items[0][1]); break; case "System.Web.UI.WebControls.RegularExpressionValidator": System.Web.UI.WebControls.RegularExpressionValidator rev = (System.Web.UI.WebControls.RegularExpressionValidator)control; Translation.TranslationRegularExpressionValidatorDB(rev, items[0][0], items[0][1]); break; } }
private void appendclick(System.Web.UI.WebControls.Button btn) { btn.Attributes.Add("onclick", "disableButtons(this);" + Page.GetPostBackEventReference(btn).ToString()); }
protected void rptList_ItemDataBound(object sender, System.Web.UI.WebControls.RepeaterItemEventArgs e) { if (e.Item.ItemType == System.Web.UI.WebControls.ListItemType.Item || e.Item.ItemType == System.Web.UI.WebControls.ListItemType.AlternatingItem) { System.Web.UI.WebControls.Repeater repeater = (System.Web.UI.WebControls.Repeater)e.Item.FindControl("rptSubList"); OrderInfo orderInfo = OrderHelper.GetOrderInfo(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "OrderID").ToString()); if (orderInfo != null && orderInfo.LineItems.Count > 0) { repeater.DataSource = orderInfo.LineItems.Values; repeater.DataBind(); } OrderStatus orderStatus = (OrderStatus)System.Web.UI.DataBinder.Eval(e.Item.DataItem, "OrderStatus"); string a = ""; if (!(System.Web.UI.DataBinder.Eval(e.Item.DataItem, "Gateway") is System.DBNull)) { a = (string)System.Web.UI.DataBinder.Eval(e.Item.DataItem, "Gateway"); } int num = (System.Web.UI.DataBinder.Eval(e.Item.DataItem, "GroupBuyId") != System.DBNull.Value) ? ((int)System.Web.UI.DataBinder.Eval(e.Item.DataItem, "GroupBuyId")) : 0; // System.Web.UI.HtmlControls.HtmlInputButton htmlInputButton = (System.Web.UI.HtmlControls.HtmlInputButton)e.Item.FindControl("btnModifyPrice"); // System.Web.UI.HtmlControls.HtmlInputButton htmlInputButton2 = (System.Web.UI.HtmlControls.HtmlInputButton)e.Item.FindControl("btnSendGoods"); System.Web.UI.WebControls.Button button = (System.Web.UI.WebControls.Button)e.Item.FindControl("btnPayOrder"); System.Web.UI.WebControls.Button button2 = (System.Web.UI.WebControls.Button)e.Item.FindControl("btnConfirmOrder"); System.Web.UI.HtmlControls.HtmlInputButton htmlInputButton3 = (System.Web.UI.HtmlControls.HtmlInputButton)e.Item.FindControl("btnCloseOrderClient"); System.Web.UI.HtmlControls.HtmlAnchor arg_198_0 = (System.Web.UI.HtmlControls.HtmlAnchor)e.Item.FindControl("lkbtnCheckRefund"); System.Web.UI.HtmlControls.HtmlAnchor arg_1AE_0 = (System.Web.UI.HtmlControls.HtmlAnchor)e.Item.FindControl("lkbtnCheckReturn"); System.Web.UI.HtmlControls.HtmlAnchor arg_1C4_0 = (System.Web.UI.HtmlControls.HtmlAnchor)e.Item.FindControl("lkbtnCheckReplace"); System.Web.UI.WebControls.Literal literal = (System.Web.UI.WebControls.Literal)e.Item.FindControl("WeiXinNickName"); System.Web.UI.WebControls.Literal literal2 = (System.Web.UI.WebControls.Literal)e.Item.FindControl("litOtherInfo"); int totalPointNumber = orderInfo.GetTotalPointNumber(); MemberInfo member = MemberProcessor.GetMember(orderInfo.UserId, true); if (member != null) { literal.Text = "买家:" + member.UserName; } System.Text.StringBuilder stringBuilder = new System.Text.StringBuilder(); decimal total = orderInfo.GetTotal(); if (total > 0m) { stringBuilder.Append("<strong>¥" + total.ToString("F2") + "</strong>"); stringBuilder.Append("<small>(含运费¥" + orderInfo.AdjustedFreight.ToString("F2") + ")</small>"); } if (totalPointNumber > 0) { stringBuilder.Append("<small>" + totalPointNumber.ToString() + "积分</small>"); } if (orderInfo.PaymentType == "货到付款") { stringBuilder.Append("<span class=\"setColor bl\"><strong>货到付款</strong></span>"); } if (string.IsNullOrEmpty(stringBuilder.ToString())) { stringBuilder.Append("<strong>¥" + total.ToString("F2") + "</strong>"); } literal2.Text = stringBuilder.ToString(); if (orderStatus == OrderStatus.WaitBuyerPay) { //htmlInputButton.Visible = true; //htmlInputButton.Attributes.Add("onclick", "DialogFrame('../trade/EditOrder.aspx?OrderId=" + System.Web.UI.DataBinder.Eval(e.Item.DataItem, "OrderID") + "&reurl='+ encodeURIComponent(goUrl),'修改订单价格',900,450)"); htmlInputButton3.Attributes.Add("onclick", "CloseOrderFun('" + System.Web.UI.DataBinder.Eval(e.Item.DataItem, "OrderID") + "')"); htmlInputButton3.Visible = true; if (a != "hishop.plugins.payment.podrequest") { button.Visible = true; } } if (num > 0) { GroupBuyStatus groupBuyStatus = (GroupBuyStatus)System.Web.UI.DataBinder.Eval(e.Item.DataItem, "GroupBuyStatus"); // htmlInputButton2.Visible = (orderStatus == OrderStatus.BuyerAlreadyPaid && groupBuyStatus == GroupBuyStatus.Success); } //else //{ // htmlInputButton2.Visible = (orderStatus == OrderStatus.BuyerAlreadyPaid || (orderStatus == OrderStatus.WaitBuyerPay && a == "hishop.plugins.payment.podrequest")); //} // htmlInputButton2.Attributes.Add("onclick", "DialogFrame('../trade/SendOrderGoods.aspx?OrderId=" + System.Web.UI.DataBinder.Eval(e.Item.DataItem, "OrderID") + "&reurl='+ encodeURIComponent(goUrl),'订单发货',750,220)"); button2.Visible = (orderStatus == OrderStatus.SellerAlreadySent); } }
void AddSmth(Object sender, EventArgs e) { System.Web.UI.WebControls.Button btn = (System.Web.UI.WebControls.Button)sender; // DES.AddSmth(btn.ID); }
public static int IndexGVButton(object sender) { System.Web.UI.WebControls.Button ct = (System.Web.UI.WebControls.Button)sender; System.Web.UI.WebControls.GridViewRow gvRow = (System.Web.UI.WebControls.GridViewRow)ct.NamingContainer; return(gvRow.RowIndex); }
public void Confirm(System.Web.UI.WebControls.Button aButton, String aMessage) { aButton.Attributes.Add("onClick", "javascript:return confirm('" + aMessage + "')"); }
private void RenderErrorPage(Bobs.SpottedException spottedEx) { HttpResponse resp = HttpContext.Current.Response; resp.Clear(); resp.StatusCode = 500; System.Web.UI.WebControls.Literal openPage = new System.Web.UI.WebControls.Literal(); openPage.Text = @" <html><head><style> .{ font-family: Verdana; font-size:12px; font-weight:bold; } p{ font-family: Verdana; font-size:12px; font-weight:bold; margin-bottom:3px; margin-top:3px; line-height:130%; } a:link, a:visited { color:#000000; } a:hover { color:#FF0000; } </style></head><body> <br> <center> <table width=""400"" cellpadding=""0"" cellspacing=""0"" border=""0""> <tr> <td valign=bottom align=left width=""100%"" rowspan=""2""> <center> <a href=""/""><img src=""/gfx/dsi-sign-100.png"" border=0 style=""border:1px solid #000000;""></a> </center> <div style=""padding:10px;""> <div style=""width:100%;border:solid 1px #000000;padding:2px 4px 2px 4px; margin:0px 0px 13px 0px;""> "; System.Web.UI.WebControls.Literal closePage = new System.Web.UI.WebControls.Literal(); closePage.Text = @" </div> </td></tr></table> </center></body></html>"; System.Web.UI.WebControls.Label exceptionLabel = new System.Web.UI.WebControls.Label(); exceptionLabel.Text = "<p>"; if (spottedEx != null && spottedEx.ExceptionType == typeof(Bobs.MalformedUrlException).ToString()) { exceptionLabel.Text += "Page not found."; } else if (spottedEx != null && (Bobs.Usr.Current != null && Bobs.Usr.Current.IsAdmin || HttpContext.Current.Request.UserHostAddress.StartsWith("84.45.14.") || HttpContext.Current.Request.UserHostAddress.StartsWith("192.168.113.") || HttpContext.Current.Request.UserHostAddress.Equals("127.0.0.1"))) { exceptionLabel.Text += spottedEx.Message + "</p><p>" + spottedEx.StackTrace; } else if (spottedEx != null && (spottedEx.ShowMessageToUsrs)) { exceptionLabel.Text += spottedEx.Message; } else { exceptionLabel.Text += "An error has occurred."; } exceptionLabel.Text += "</p><p><br></p><p>If this problem persists, you may wish to report this to an Admin"; if (spottedEx != null && spottedEx.K > 0) exceptionLabel.Text += ", quoting error #" + spottedEx.K; exceptionLabel.Text += ".</p>"; System.Web.UI.WebControls.Button retryButton = new System.Web.UI.WebControls.Button(); retryButton.Text = "Retry"; retryButton.OnClientClick = "location.reload();"; System.Web.UI.WebControls.Button historyBackButton = new System.Web.UI.WebControls.Button(); historyBackButton.Text = "Back"; historyBackButton.OnClientClick = @"history.back();"; System.Web.UI.WebControls.Button homeButton = new System.Web.UI.WebControls.Button(); homeButton.Text = "Home"; homeButton.OnClientClick = @"location = ""/"";"; System.IO.StringWriter stringWriter = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter htmlWriter = new System.Web.UI.HtmlTextWriter(stringWriter); openPage.RenderControl(htmlWriter); exceptionLabel.RenderControl(htmlWriter); htmlWriter.RenderBeginTag("center"); retryButton.RenderControl(htmlWriter); historyBackButton.RenderControl(htmlWriter); homeButton.RenderControl(htmlWriter); htmlWriter.RenderEndTag(); closePage.RenderControl(htmlWriter); resp.Write(stringWriter.ToString()); }
protected void CheckActionPermissions(string actionValue, System.Web.UI.WebControls.Button btnTemp) { return; }