2015-01-07 46 views
0

這樣的,我有我的身邊hidde而是由隱藏在重塑的名字,我想保持它在你的名字和不添加任何東西更多,改寫名字爲它工作 - 保持它的真實姓名

問題我想只是名稱具有唯一協議,不應該超過其添加到這一點:

<input type="hidden" name="ctl00$ContentPlaceHolder1$protocol" id="ContentPlaceHolder1_protocol" value="7" /> 

則它必須是這樣的,沒有我不能只使用HTML,

<input type="hidden" name="protocol" id="protocol" value="7" /> 

這裏是我用於頁面的代碼。

<asp:HiddenField ID="protocol" runat="server" /> 
<asp:HiddenField ID="msgtype" runat="server" /> 
<asp:HiddenField ID="merchant" runat="server" /> 
<asp:HiddenField ID="language" runat="server" /> 
<asp:HiddenField ID="ordernumber" runat="server" /> 
<asp:HiddenField ID="amount" runat="server" /> 
<asp:HiddenField ID="currency" runat="server" /> 
<asp:HiddenField ID="continueurl" runat="server" /> 
<asp:HiddenField ID="cancelurl" runat="server" /> 
<asp:HiddenField ID="callbackurl" runat="server" /> 
<asp:HiddenField ID="autocapture" runat="server" /> 
<asp:HiddenField ID="md5check" runat="server" /> 

這是我如何打印它當前頁,該值值

string protocol_value = "7"; 
      string msgtype_value = "authorize"; 
      string language_value = "da"; 
      string autocapture_value = "0"; 
      string ordernum_value = Session["orderId"].ToString(); 
      string merchant_value = "89898978"; 
      string amount_value = readerPriser["priser"].ToString(); 
      string qp_currency_value = "DKK"; 
      string okpage_value = "../handelsbetingelserContinue.aspx"; 
      string errorPage_value = "../handelsbetingelserCallback.aspx"; 
      string resultpage_value = "../handelsbetingelserError.aspx"; 
      string md5secret_value = "29p61DveBZ79c3144LW61lVz1qrwk2gfAFCxPyi5sn49m3Y3IRK5M6SN5d8a68u7"; 
      string md5check_value = GenerateHash(string.Concat(protocol_value.ToString(), msgtype_value, merchant_value, language_value, ordernum_value, amount_value.ToString(), qp_currency_value, okpage_value, errorPage_value, resultpage_value, 
      autocapture_value.ToString(), md5secret_value)); 

      protocol.Value = protocol_value; 
      msgtype.Value = msgtype_value; 
      language.Value = language_value; 
      autocapture.Value = autocapture_value; 
      ordernumber.Value = ordernum_value; 
      merchant.Value = merchant_value; 
      amount.Value = amount_value; 
      currency.Value = qp_currency_value; 
      continueurl.Value = okpage_value; 
      cancelurl.Value = errorPage_value; 
      callbackurl.Value = resultpage_value; 
      md5check.Value = md5check_value; 
+0

如果指定的屬性是什麼? '' – Alex

+2

http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientidmode %28v = vs.110%29.aspx – SearchAndResQ

回答

0

上嘗試這種情況:

<asp:HiddenField ID="protocol" runat="server" ClientIDMode="Static" /> 

ASP.NET提供了生成的客戶端ID的四種模式:

  • AutoID
  • 靜態
  • 預測
  • 繼承

在這裏,你可能會發現細節: http://msdn.microsoft.com/en-us/library/system.web.ui.control.clientidmode%28v=vs.110%29.aspx

+0

它不會工作, – Jesper

+0

我試着在這裏:'LiteralProtocol.Text =「';' – Jesper

+0

Landeeyo的答案是正確的。但是,如果你在文字中創建html元素,不要期望.NET能夠將值從它們中取出。你是否試圖使用JavaScript從隱藏字段中獲取這些值? –