简体   繁体   English

从C#发布隐藏的字段和值

[英]Posting hidden field and values from C#

Hi I am trying to achieve following in c# where I want to post xml data to a url where cxml-urlencoded is an hidden field. 嗨,我正在尝试在c#中实现以下目标,我想将xml数据发布到其中cxml-urlencoded是隐藏字段的URL。

<FORM METHOD=POST ACTION=<%= url%>>
<INPUT TYPE=HIDDEN NAME="cxml-urlencoded" VALUE="<% CreateCXML toUser,
fromUser, buyerCookie, unitPrice, supPartId, supPartAuxId, desc%>">
<INPUT TYPE=SUBMIT value=BUY>
</FORM>

I tried doing it 我尝试过

string  myurl=(uri+Server.UrlEncode(str1));
      Response.Write(@"<a input type=""hidden"" name=""cxml-urlencoded"" value=""myurl""></a>"); 
      Response.Close();

Any ideas how to best go about it? 有什么想法最好地去做吗?

Insert a HiddenField server control in the page 在页面中插入一个HiddenField服务器控件

<asp:HiddenField runat="server" ID="hdXML"/>

and set the value in the hidden fields from code behind as 并在后面的代码中的隐藏字段中将值设置为

hdXml.Value = CreateCXML(toUser, fromUser, buyerCookie, unitPrice, supPartId, supPartAuxId, desc);

Make sure you have the CreateCXML function declared and returning string. 确保您已声明CreateCXML函数并返回字符串。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM