本文整理汇总了C#中HiddenField类的典型用法代码示例。如果您正苦于以下问题:C# HiddenField类的具体用法?C# HiddenField怎么用?C# HiddenField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
HiddenField类属于命名空间,在下文中一共展示了HiddenField类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateChildControls
protected override void CreateChildControls()
{
_state = new HiddenField {ID = ID + "_state"};
_state.ValueChanged += HandleLinkRequest;
Controls.Add(_state);
}
示例2: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
// Set body to submit onload
body.Attributes.Add("onload", "document.forms[0].submit()");
// Set form action and method
paypalForm.Action = "https://www.sandbox.paypal.com/cgi-bin/webscr"; // TEST URL
paypalForm.Method = "POST";
// Retrieve donations from the session
var donations = BusinessLogic.Donation.GetDonations();
// Determine donation type
if (donations.Count() > 1)
{
this.processingType = ProcessingType.Cart;
}
else
{
if (donations.First().DonationType == "Special")
{
this.processingType = ProcessingType.OneTime;
}
else
{
this.processingType = ProcessingType.Recurring;
}
}
// Create collection to store values in
Dictionary<string, string> formValues = new Dictionary<string, string>();
// Set default values
formValues.Add("business", "[email protected]");
formValues.Add("no_shipping", "2");
formValues.Add("currency_code", "USD");
formValues.Add("tax", "0");
formValues.Add("no_note", "1");
// Add type specific values to collection
var addedFormValues = this.AddTypeSpecificValues(donations);
addedFormValues.ToList().ForEach(x => formValues.Add(x.Key, x.Value));
// Add hidden fields to form
foreach (KeyValuePair<string, string> pair in formValues)
{
HiddenField field = new HiddenField();
field.ID = (string)pair.Key;
field.Value = (string)pair.Value;
paypalForm.Controls.Add(field);
}
// Clear session so that donations are not saved when the user returns
BusinessLogic.Donation.ClearDonations();
}
示例3: PopulateHiddenField
/// <summary>
/// Populates the value of the specified hidden field with the data
/// associated with the specified querystring param. Populates the
/// field with an empty string if parameter does not exist.
/// </summary>
/// <param name="hiddenField">HiddenField to populate</param>
/// <param name="queryStringParam">Query string parameter</param>
private void PopulateHiddenField(HiddenField hiddenField, string queryStringParam)
{
if (!string.IsNullOrEmpty(Request.QueryString[queryStringParam]))
{
hiddenField.Value = Request.QueryString[queryStringParam];
}
else
{
hiddenField.Value = string.Empty;
}
}
示例4: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
if (PreviousPage != null)
{
ob = (HiddenField)PreviousPage.FindControl("HiddenFieldconstituencyId");
}
if (ob != null)
{
Int16 constituencyId = Convert.ToInt16(ob.Value);
loadmpdetails(constituencyId);
}
}
示例5: GridView1_RowDataBound
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
OperaterDropDownList = (DropDownList)e.Row.Cells[1].FindControl("selOperator");
OperaterDropDownList.Attributes.Add("onchange", "OperatorChange(this);");
// add by zy 20110107 start
string fieldName = ((System.Data.DataRowView)(e.Row.DataItem)).Row.ItemArray[2].ToString();
TextBox TBCondiction1 = (TextBox)e.Row.Cells[2].FindControl("txtCondition1");
HtmlImage IBSelect = (HtmlImage)e.Row.Cells[3].FindControl("imgSelect");
IBSelect.Attributes.Add("onclick", string.Format("topopmask('../SelectReportCondiction.aspx',800,450,'Select Report Condition','{0}','{1}');", TBCondiction1.ClientID, fieldName));
// add by zy 20110107 end
FieldTypeHiddenField = (HiddenField)e.Row.Cells[3].FindControl("hidFieldType");
BoundOperater(OperaterDropDownList, FieldTypeHiddenField.Value);
}
}
示例6: CreatePageControl
private void CreatePageControl()
{
// Create dynamic controls here.
btnNextPage = new Button();
btnNextPage.ID = "btnNextPage";
Form1.Controls.Add(btnNextPage);
btnNextPage.Click += new System.EventHandler(btnNextPage_Click);
btnPreviousPage = new Button();
btnPreviousPage.ID = "btnPreviousPage";
Form1.Controls.Add(btnPreviousPage);
btnPreviousPage.Click += new System.EventHandler(btnPreviousPage_Click);
btnGoPage = new Button();
btnGoPage.ID = "btnGoPage";
Form1.Controls.Add(btnGoPage);
btnGoPage.Click += new System.EventHandler(btnGoPage_Click);
HFD_CurrentPage = new HiddenField();
HFD_CurrentPage.Value = "1";
HFD_CurrentPage.ID = "HFD_CurrentPage";
Form1.Controls.Add(HFD_CurrentPage);
}
示例7: Page_Load
protected void Page_Load(object sender, EventArgs e)
{
((BXAdminMasterPage)Page.Master).Title = Page.Title;
if (userId > 0)
BXRoleManager.SynchronizeProviderUserRoles(user.UserName, user.ProviderName);
var filter = new BXFormFilter(
new BXFormFilterItem("Active", true, BXSqlFilterOperators.Equal)
);
var roles = userId > 0 ? rolesToViewAndModify : rolesToCreate;
if (roles.Length != 1 || roles[0] != 0)
filter.Add(new BXFormFilterItem("Id", roles, BXSqlFilterOperators.In));
BXRoleCollection rolesTmp = BXRoleManager.GetList(
filter,
new BXOrderBy_old("RoleName", "Asc")
);
foreach (int i in new[] { 1, 3, 2 })
{
var r = rolesTmp.Find(x => x.RoleId == i);
if (r != null)
{
rolesTmp.Remove(r);
rolesTmp.Insert(0, r);
}
}
foreach (BXRole roleTmp in rolesTmp)
{
HtmlTableRow r1 = new HtmlTableRow();
r1.VAlign = "top";
HtmlTableCell c1 = new HtmlTableCell();
CheckBox cb = new CheckBox();
cb.ID = String.Format("tbCheck_{0}", roleTmp.RoleId.ToString());
cb.Checked = false;
c1.Controls.Add(cb);
HiddenField hf = new HiddenField();
hf.ID = String.Format("tbCheck_{0}_old", roleTmp.RoleId.ToString());
hf.Value = "N";
c1.Controls.Add(hf);
r1.Cells.Add(c1);
c1 = new HtmlTableCell();
c1.InnerHtml = String.Format("<a href=\"AuthRolesEdit.aspx?name={0}\">{1}</a>", Server.UrlEncode(roleTmp.RoleName), Server.HtmlEncode(roleTmp.Title));
r1.Cells.Add(c1);
c1 = new HtmlTableCell();
c1.Align = "center";
c1.Style["padding-right"] = "10px";
c1.Style["padding-left"] = "10px";
TextBox tb1 = new TextBox();
tb1.ID = String.Format("tbActiveFrom_{0}", roleTmp.RoleId.ToString());
c1.InnerHtml = "c ";
c1.Controls.Add(tb1);
hf = new HiddenField();
hf.ID = String.Format("tbActiveFrom_{0}_old", roleTmp.RoleId.ToString());
hf.Value = "";
c1.Controls.Add(hf);
r1.Cells.Add(c1);
c1 = new HtmlTableCell();
c1.Align = "center";
tb1 = new TextBox();
tb1.ID = String.Format("tbActiveTo_{0}", roleTmp.RoleId.ToString());
c1.InnerHtml = string.Format("{0} ", GetMessage("TabCellInnerHtml.To"));
c1.Controls.Add(tb1);
hf = new HiddenField();
hf.ID = String.Format("tbActiveTo_{0}_old", roleTmp.RoleId.ToString());
hf.Value = "";
c1.Controls.Add(hf);
r1.Cells.Add(c1);
tblRoles.Rows.Add(r1);
}
if (!Page.IsPostBack)
LoadData();
if (userId > 0)
{
if (!missingProvider)
{
trPasswordQuestion.Style["display"] = (Membership.Providers[user.ProviderName].RequiresQuestionAndAnswer ? "" : "none");
trPasswordAnswer.Style["display"] = (Membership.Providers[user.ProviderName].RequiresQuestionAndAnswer ? "" : "none");
}
else
{
trPasswordQuestion.Style["display"] = "none";
trPasswordAnswer.Style["display"] = "none";
trPassword.Style["display"] = "none";
trNewPassword.Style["display"] = "none";
trNewPasswordConf.Style["display"] = "none";
}
}
else
{
//.........这里部分代码省略.........
示例8: CreatePageControl
private void CreatePageControl()
{
// Create dynamic controls here.
btnNextPage = new Button();
btnNextPage.ID = "btnNextPage";
btnNextPage.Height = 1;
btnNextPage.Width = 1;
Form1.Controls.Add(btnNextPage);
btnNextPage.Click += new System.EventHandler(btnNextPage_Click);
btnPreviousPage = new Button();
btnPreviousPage.ID = "btnPreviousPage";
Form1.Controls.Add(btnPreviousPage);
btnPreviousPage.Click += new System.EventHandler(btnPreviousPage_Click);
btnGoPage = new Button();
btnGoPage.ID = "btnGoPage";
Form1.Controls.Add(btnGoPage);
btnGoPage.Click += new System.EventHandler(btnGoPage_Click);
HFD_CurrentPage = new HiddenField();
HFD_CurrentPage.Value = "1";
HFD_CurrentPage.ID = "HFD_CurrentPage";
Form1.Controls.Add(HFD_CurrentPage);
HFD_CurrentSortField = new HiddenField();
HFD_CurrentSortField.Value = "";
HFD_CurrentSortField.ID = "HFD_CurrentSortField";
Form1.Controls.Add(HFD_CurrentSortField);
HFD_CurrentSortDir = new HiddenField();
HFD_CurrentSortDir.Value = "asc";
HFD_CurrentSortDir.ID = "HFD_CurrentSortDir";
Form1.Controls.Add(HFD_CurrentSortDir);
}
示例9: readPage
public void readPage(SqlConnection con)
{
string value = Context.Request["it"];
if (value == null)
return;
((HiddenField)Master.FindControl("PageIndex")).Value = value;
SqlCommand cmd = new SqlCommand("SELECT * FROM [Url] WHERE [it] = @it ORDER BY [index]", con);
cmd.Parameters.AddWithValue("@it", value);
SqlDataReader reader = cmd.ExecuteReader();
for (int i = 1; reader.Read(); i++)
{
HiddenField hid = new HiddenField();
hid.ID = "page" + i.ToString();
hid.Value = reader["url"].ToString();
Url.Controls.Add(hid);
}
reader.Close();
}
示例10: SetHiddenValues
/// <summary>
/// Sets array list values into hidden field.
/// </summary>
/// <param name="values">Arraylist of values to selection</param>
/// <param name="field">Hidden field</param>
private static void SetHiddenValues(ArrayList values, HiddenField actionsField, HiddenField hashField)
{
if (values != null)
{
if (actionsField != null)
{
// Build the list of actions
StringBuilder sb = new StringBuilder();
sb.Append("|");
foreach (object value in values)
{
sb.Append(value);
sb.Append("|");
}
// Action IDs
string actions = sb.ToString();
actionsField.Value = actions;
// Actions hash
if (hashField != null)
{
hashField.Value = ValidationHelper.GetHashString(actions);
}
}
}
}
示例11: GetHiddenValues
/// <summary>
/// Returns array list from hidden field.
/// </summary>
/// <param name="field">Hidden field with values separated with |</param>
private static ArrayList GetHiddenValues(HiddenField field)
{
string hiddenValue = field.Value.Trim('|');
ArrayList list = new ArrayList();
string[] values = hiddenValue.Split('|');
foreach (string value in values)
{
if (!list.Contains(value))
{
list.Add(value);
}
}
list.Remove("");
return list;
}
示例12: ClearHiddenValues
/// <summary>
/// Clears all selected items from hidden values.
/// </summary>
/// <param name="field">Hidden field</param>
private static void ClearHiddenValues(HiddenField field)
{
if (field != null)
{
field.Value = "";
}
}
示例13: ValidateHiddenValues
/// <summary>
/// Validates values in hidden fields with corresponding hash.
/// </summary>
/// <param name="field">Hidden field with values separated with |</param>
/// <param name="hashField">Hidden field containing hash of <paramref name="field"/></param>
private static bool ValidateHiddenValues(HiddenField field, HiddenField hashField)
{
return ValidationHelper.ValidateHash(field.Value, hashField.Value, redirect: false);
}
示例14: GetHiddenValues
/// <summary>
/// Returns array list from hidden field.
/// </summary>
/// <param name="field">Hidden field with values separated with |</param>
/// <param name="hashField">Hidden field containing hash of <paramref name="field"/></param>
private static List<string> GetHiddenValues(HiddenField field, HiddenField hashField)
{
var result = new List<string>();
if (ValidateHiddenValues(field, hashField))
{
result.AddRange(field.Value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries).Distinct(StringComparer.InvariantCultureIgnoreCase).ToList());
}
return result;
}
示例15: ClearHiddenValues
/// <summary>
/// Clears all selected items from hidden values.
/// </summary>
/// <param name="field">Hidden field</param>
private static void ClearHiddenValues(HiddenField field)
{
if (field != null)
{
field.Value = String.Empty;
}
}