本文整理汇总了C#中HtmlTextWriter.WriteEncodedUrl方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlTextWriter.WriteEncodedUrl方法的具体用法?C# HtmlTextWriter.WriteEncodedUrl怎么用?C# HtmlTextWriter.WriteEncodedUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HtmlTextWriter
的用法示例。
在下文中一共展示了HtmlTextWriter.WriteEncodedUrl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderPostBackEvent
/// <devdoc>
/// <para>Renders a client widget corresponding to a postback event, for example a wml do or a post link. Note that this
/// widget may not submit the form data, e.g. scriptless html where this renders a link. </para>
/// </devdoc>
protected void RenderPostBackEvent(HtmlTextWriter writer, string target, string argument, string softkeyLabel, string text, string postUrl, string accessKey, bool encode) {
// Default: render postback event as scriptless anchor (works for all markups). Override for specific markups.
string amp = encode ? "&" : "&";
bool isCrossPagePostBack = !String.IsNullOrEmpty(postUrl);
writer.WriteBeginTag("a");
writer.Write(" href=\"");
string url = null;
if (!isCrossPagePostBack) {
if ((String)Browser["requiresAbsolutePostbackUrl"] == "true") {
url = Page.Response.ApplyAppPathModifier(Page.Request.CurrentExecutionFilePath);
}
else {
url = Page.RelativeFilePath;
}
}
else {
url = postUrl;
Page.ContainsCrossPagePost = true;
}
writer.WriteEncodedUrl(url);
writer.Write("?");
string clientState = ClientState;
if (clientState != null)
{
ICollection chunks = Page.DecomposeViewStateIntoChunks();
// Default chunk count is 1
if (chunks.Count > 1) {
writer.Write(Page.ViewStateFieldCountID + "=" + chunks.Count + amp);
}
int count = 0;
foreach (String state in chunks) {
writer.Write(Page.ViewStateFieldPrefixID);
if (count > 0) writer.Write(count.ToString(CultureInfo.CurrentCulture));
writer.Write("=" + HttpUtility.UrlEncode(state));
writer.Write(amp);
++count;
}
}
if (isCrossPagePostBack) {
writer.Write(Page.previousPageID);
writer.Write("=" + Page.EncryptString(Page.Request.CurrentExecutionFilePath, Purpose.WebForms_Page_PreviousPageID));
writer.Write(amp);
}
writer.Write("__EVENTTARGET=" + HttpUtility.UrlEncode(target));
writer.Write(amp);
writer.Write("__EVENTARGUMENT=" + HttpUtility.UrlEncode(argument));
//
string queryStringText = QueryString;
if (!String.IsNullOrEmpty(queryStringText)) {
writer.Write(amp);
writer.Write(queryStringText);
}
writer.Write("\"");
if (!String.IsNullOrEmpty(accessKey)) {
writer.WriteAttribute("accessKey", accessKey);
}
writer.Write(">");
writer.Write(text);
writer.WriteEndTag("a");
}