本文整理汇总了C#中XhtmlMobileTextWriter.WriteAttribute方法的典型用法代码示例。如果您正苦于以下问题:C# XhtmlMobileTextWriter.WriteAttribute方法的具体用法?C# XhtmlMobileTextWriter.WriteAttribute怎么用?C# XhtmlMobileTextWriter.WriteAttribute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XhtmlMobileTextWriter
的用法示例。
在下文中一共展示了XhtmlMobileTextWriter.WriteAttribute方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RenderAsInputTypeImage
private void RenderAsInputTypeImage(XhtmlMobileTextWriter writer) {
ConditionalEnterStyle(writer, Style);
writer.WriteBeginTag("input");
writer.WriteAttribute("type", "image");
writer.WriteAttribute("name", Control.UniqueID);
writer.WriteAttribute("src", Control.ResolveUrl(Control.ImageUrl), true);
writer.WriteAttribute("alt", Control.Text, true);
ConditionalRenderClassAttribute(writer);
ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute);
writer.Write("/>");
// ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
// ConditionalExitStyle may render a block element and clear the pending break.
ConditionalSetPendingBreakAfterInline(writer);
ConditionalExitStyle(writer, Style);
}
示例2: Render
/// <include file='doc\XhtmlBasicTextBoxAdapter.uex' path='docs/doc[@for="XhtmlTextBoxAdapter.Render"]/*' />
public override void Render(XhtmlMobileTextWriter writer) {
ConditionalClearPendingBreak(writer);
ConditionalEnterStyle(writer, Style);
ConditionalRenderOpeningSpanElement(writer);
if ((String) Device[XhtmlConstants.RequiresOnEnterForward] == "true") {
writer.AddOnEnterForwardSetVar(Control.UniqueID, Control.Text);
}
writer.WriteBeginTag("input");
writer.WriteAttribute("name", Control.UniqueID);
ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute);
String controlText = Control.Text;
if (controlText != null && controlText.Length > 0 && !Control.Password) {
writer.Write(" value=\"");
writer.WriteEncodedText(controlText);
writer.Write("\"");
}
if (Control.Size > 0) {
writer.WriteAttribute("size", Control.Size.ToString(CultureInfo.InvariantCulture));
}
if (Control.MaxLength > 0) {
writer.WriteAttribute("maxlength", Control.MaxLength.ToString(CultureInfo.InvariantCulture));
}
String requiresType = Device["requiresInputTypeAttribute"];
if (Control.Password) {
writer.WriteAttribute("type", "password");
}
// InvariantCulture not needed, but included for best practices.
else if (requiresType != null && String.Equals(requiresType, "true", StringComparison.OrdinalIgnoreCase)) {
writer.WriteAttribute("type", "text");
}
writer.Write("/>");
// ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
// ConditionalExitStyle may render a block element and clear the pending break.
ConditionalSetPendingBreakAfterInline(writer);
ConditionalRenderClosingSpanElement(writer);
ConditionalExitStyle(writer, Style);
}
示例3: RenderImage
/// <include file='doc\XhtmlBasicImageAdapter.uex' path='docs/doc[@for="XhtmlImageAdapter.RenderImage"]/*' />
protected virtual void RenderImage(XhtmlMobileTextWriter writer) {
String source = Control.ImageUrl;
writer.WriteBeginTag("img");
if(source != null && source.Length > 0) {
source = Page.Server.UrlPathEncode(Control.ResolveUrl(source.Trim()));
writer.WriteAttribute("src", source, true);
writer.AddResource(source);
}
String alternateText = Control.AlternateText;
if (alternateText == null || alternateText.Length == 0) {
alternateText = " "; // ASURT 143759 and VSWhidbey 78593
}
writer.WriteAttribute("alt", alternateText, true);
// Review: Html adapter writes border=0 attribute, but don't need this here?
writer.Write(" />");
}
示例4: ConditionalRenderOpeningDivElement
// Render opening <div class=...> in case the stylesheet location has been specified as a physical file.
/// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalRenderOpeningDivElement"]/*' />
protected virtual void ConditionalRenderOpeningDivElement(XhtmlMobileTextWriter writer) {
if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] == "true") {
return;
}
String classAttribute = (String) Control.CustomAttributes[XhtmlConstants.CssClassCustomAttribute];
if (CssLocation == StyleSheetLocation.PhysicalFile) {
writer.WriteLine();
if ((String)Device["usePOverDiv"] == "true") {
writer.WriteBeginTag("p");
}
else {
writer.WriteBeginTag("div");
}
if (classAttribute != null &&
classAttribute.Length > 0 &&
writer.DiffersFromCurrentPhysicalCssClass(classAttribute)) {
writer.WriteAttribute("class", classAttribute, true);
writer.PushPhysicalCssClass(classAttribute);
Debug.Assert(!_physicalCssClassPushed, "These calls should not be nested.");
_physicalCssClassPushed = true;
}
writer.Write(">");
}
}
示例5: RenderBeginLink
/// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderBeginLink"]/*' />
protected virtual void RenderBeginLink(XhtmlMobileTextWriter writer, String target, String accessKey, Style style, String cssClass, String title) {
writer.WriteBeginTag("a");
writer.Write(" href=\"");
RenderHrefValue (writer, target);
writer.Write("\"");
if (accessKey != null && accessKey.Length > 0) {
writer.WriteAttribute("accesskey", accessKey, true);
}
if (CssLocation != StyleSheetLocation.PhysicalFile) {
String className = writer.GetCssFormatClassName(style);
if (className != null) {
writer.WriteAttribute ("class", className);
}
}
else if (cssClass != null && cssClass.Length > 0) {
writer.WriteAttribute ("class", cssClass, true /* encode */);
}
if (title != null && title.Length > 0) {
writer.WriteAttribute("title", title, true /* encode */);
}
writer.WriteLine(">");
}
示例6: Render
/// <include file='doc\XhtmlBasicFormAdapter.uex' path='docs/doc[@for="XhtmlFormAdapter.Render"]/*' />
public override void Render (XhtmlMobileTextWriter writer) {
// Note: <head>, <body> rendered by page adapter, as in HTML case.
String formsAuthCookieName = FormsAuthentication.FormsCookieName;
if(!Device.SupportsRedirectWithCookie)
{
if(formsAuthCookieName != null && formsAuthCookieName.Length > 0)
{
HttpContext.Current.Response.Cookies.Remove(formsAuthCookieName);
}
}
writer.WriteBeginTag ("form");
writer.WriteAttribute ("id", Control.ClientID);
writer.WriteAttribute ("method", Control.Method.ToString().ToLower(CultureInfo.CurrentCulture));
writer.Write (" action=\"");
RenderPostbackUrl(writer);
if(Control.Action.Length > 0) {
if(Control.Action.IndexOf("?", StringComparison.Ordinal) != -1) {
writer.Write("&");
}
else {
writer.Write("?");
}
}
else {
writer.Write("?");
}
writer.Write(Page.UniqueFilePathSuffix);
if (Control.Method != FormMethod.Get &&
Control.Action.Length == 0) { // VSWhidbey 411176: We don't include QueryStringText if Action is explicitly set
String queryStringText = PreprocessQueryString(Page.QueryStringText);
if (queryStringText != null && queryStringText.Length > 0) {
String amp = (String)Device[XhtmlConstants.SupportsUrlAttributeEncoding] != "false" ? "&" : "&";
writer.Write(amp);
if((String)Device[XhtmlConstants.SupportsUrlAttributeEncoding] != "false") {
writer.WriteEncodedText(queryStringText);
}
else {
writer.Write(queryStringText);
}
}
}
writer.WriteLine ("\">");
bool needDivStyle = (String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true" &&
(String)Device["supportsBodyClassAttribute"] == "false";
if (!needDivStyle) {
if((String)Device["usePOverDiv"] == "true")
writer.WriteFullBeginTag("p");
else
writer.WriteFullBeginTag ("div");
}
else {
if((String)Device["usePOverDiv"] == "true")
writer.EnterStyle(Style, "p");
else
writer.EnterStyle (Style, "div");
}
RenderPostBackHeader (writer);
// Renders hidden variables for IPostBackDataHandlers which are
// not displayed due to pagination or secondary UI.
RenderOffPageVariables(writer, Control, Control.CurrentPage);
RenderChildren (writer);
if (!needDivStyle) {
if((String)Device["usePOverDiv"] == "true")
writer.WriteEndTag("p");
else
writer.WriteEndTag ("div");
}
else {
if((String)Device["usePOverDiv"] == "true")
writer.ExitStyle(Style);
else
writer.ExitStyle (Style);
}
writer.WriteEndTag ("form");
}
示例7: RenderPagerTag
/// <include file='doc\XhtmlBasicFormAdapter.uex' path='docs/doc[@for="XhtmlFormAdapter.RenderPagerTag"]/*' />
protected virtual void RenderPagerTag(
XhtmlMobileTextWriter writer,
int pageToNavigate,
String text,
String accessKeyCustomAttribute) {
writer.WriteBeginTag("input");
// Specially encode the page number with the control id.
// The corresponding code that handles postback should know how
// to extract the page number correctly.
writer.Write(" name=\"");
writer.Write(Control.UniqueID);
writer.Write(Constants.PagePrefix);
writer.Write(pageToNavigate.ToString(CultureInfo.InvariantCulture));
writer.Write("\"");
writer.WriteAttribute("type", "submit");
writer.WriteAttribute("value", text, true);
ConditionalRenderCustomAttribute(writer, accessKeyCustomAttribute, XhtmlConstants.AccessKeyCustomAttribute);
writer.Write("/>");
}
示例8: RenderSelectElement
void RenderSelectElement (XhtmlMobileTextWriter writer) {
if ((String)Device["supportsSelectFollowingTable"] == "false" && writer.CachedEndTag == "table") {
writer.Write(" ");
}
ConditionalEnterStyle(writer, Style);
writer.WriteBeginTag ("select");
if (Control.SelectType == ListSelectType.MultiSelectListBox) {
writer.WriteAttribute ("multiple", "multiple");
}
if (Control.SelectType == ListSelectType.ListBox || Control.SelectType == ListSelectType.MultiSelectListBox) {
writer.WriteAttribute ("size", Control.Rows.ToString(CultureInfo.InvariantCulture));
}
writer.WriteAttribute ("name", Control.UniqueID);
ConditionalRenderClassAttribute(writer);
writer.Write (">");
for (int itemIndex = 0; itemIndex < Control.Items.Count; itemIndex++) {
MobileListItem item = Control.Items[itemIndex];
writer.WriteBeginTag ("option");
WriteItemValueAttribute (writer, itemIndex, item.Value);
if (item.Selected && (Control.IsMultiSelect || itemIndex == Control.SelectedIndex)) {
writer.Write (" selected=\"selected\">");
}
else {
writer.Write (">");
}
writer.WriteEncodedText (item.Text);
writer.WriteLine ("</option>");
}
ConditionalSetPendingBreak(writer);
writer.WriteEndTag ("select");
writer.WriteLine ();
ConditionalPopPhysicalCssClass(writer);
ConditionalExitStyle(writer, Style);
}
示例9: RenderItemsListWithoutTableTags
private void RenderItemsListWithoutTableTags(XhtmlMobileTextWriter writer)
{
if (Control.VisibleItemCount == 0) {
return;
}
ConditionalRenderOpeningDivElement(writer);
int startIndex = Control.FirstVisibleItemIndex;
int pageSize = Control.VisibleItemCount;
ObjectListItemCollection items = Control.Items;
IObjectListFieldCollection allFields = Control.AllFields;
int count = allFields.Count;
int nextStartIndex = startIndex + pageSize;
int labelFieldIndex = Control.LabelFieldIndex;
Style style = this.Style;
Style labelStyle = Control.LabelStyle;
String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
String labelClass = GetCustomAttributeValue(XhtmlConstants.CssLabelClassCustomAttribute);
if (labelClass == null || labelClass.Length == 0) {
labelClass = cssClass;
}
ConditionalEnterStyle(writer, labelStyle);
bool requiresLabelClassSpan = CssLocation == StyleSheetLocation.PhysicalFile && labelClass != null && labelClass.Length > 0;
if (requiresLabelClassSpan) {
writer.WriteBeginTag("span");
writer.WriteAttribute("class", labelClass, true);
writer.Write(">");
}
writer.Write(Control.AllFields[labelFieldIndex].Title);
writer.SetPendingBreak();
if (requiresLabelClassSpan) {
writer.WriteEndTag("span");
}
ConditionalExitStyle(writer, labelStyle);
writer.WritePendingBreak();
bool hasDefaultCommand = HasDefaultCommand();
bool onlyHasDefaultCommand = OnlyHasDefaultCommand();
bool requiresDetailsScreen = !onlyHasDefaultCommand && HasCommands();
// if there is > 1 visible field, need a details screen
for (int visibleFields = 0, i = 0; !requiresDetailsScreen && i < count; i++) {
visibleFields += allFields[i].Visible ? 1 : 0;
requiresDetailsScreen =
requiresDetailsScreen || visibleFields > 1;
}
bool itemRequiresHyperlink = requiresDetailsScreen || hasDefaultCommand;
bool itemRequiresMoreButton = requiresDetailsScreen && hasDefaultCommand;
Style subCommandStyle = Control.CommandStyle;
subCommandStyle.Alignment = style.Alignment;
subCommandStyle.Wrapping = style.Wrapping;
ConditionalEnterStyle(writer, style);
for (int i = startIndex; i < nextStartIndex; i++) {
ObjectListItem item = items[i];
String accessKey = GetCustomAttributeValue(item, XhtmlConstants.AccessKeyCustomAttribute);
String itemClass = GetCustomAttributeValue(item, XhtmlConstants.CssClassCustomAttribute);
if (itemRequiresHyperlink) {
RenderPostBackEventAsAnchor(writer,
hasDefaultCommand ?
item.Index.ToString(CultureInfo.InvariantCulture) :
String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index),
item[labelFieldIndex], accessKey, Style, cssClass);
}
else {
bool requiresItemClassSpan = CssLocation == StyleSheetLocation.PhysicalFile && itemClass != null && itemClass.Length > 0;
if (requiresItemClassSpan) {
writer.WriteBeginTag("span");
writer.WriteAttribute("class", itemClass, true);
writer.Write(">");
}
writer.Write(item[labelFieldIndex]);
if (requiresItemClassSpan) {
writer.WriteEndTag("span");
}
}
if (itemRequiresMoreButton) {
String commandClass = GetCustomAttributeValue(XhtmlConstants.CssCommandClassCustomAttribute);
BooleanOption cachedItalic = subCommandStyle.Font.Italic;
subCommandStyle.Font.Italic = BooleanOption.False;
ConditionalEnterFormat(writer, subCommandStyle);
if ((String)Device[XhtmlConstants.BreaksOnInlineElements] != "true") {
writer.Write(" [");
}
ConditionalExitFormat(writer, subCommandStyle);
subCommandStyle.Font.Italic = cachedItalic;
ConditionalEnterFormat(writer, subCommandStyle);
String controlMT = Control.MoreText;
String moreText = (controlMT == null || controlMT.Length == 0) ?
GetDefaultLabel(MoreLabel) :
controlMT;
RenderPostBackEventAsAnchor(writer,
String.Format(CultureInfo.InvariantCulture, ShowMoreFormat, item.Index),
//.........这里部分代码省略.........
示例10: RenderPostBackEventAsAnchor
// For Style/CssClass args, see ASURT 144034
/// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.RenderPostBackEventAsAnchor2"]/*' />
protected virtual void RenderPostBackEventAsAnchor (
XhtmlMobileTextWriter writer,
String argument,
String linkText,
String accessKey,
Style style,
String cssClass) {
writer.WriteBeginTag("a");
writer.Write(" href=\"");
PageAdapter.RenderUrlPostBackEvent(writer, Control.UniqueID /* target */, argument);
writer.Write("\" ");
if (accessKey != null && accessKey.Length > 0) {
writer.WriteAttribute("accesskey", accessKey);
}
if ((String)Device[XhtmlConstants.RequiresXhtmlCssSuppression] != "true") {
if (CssLocation != StyleSheetLocation.PhysicalFile) {
String className = writer.GetCssFormatClassName(style);
if (className != null) {
writer.WriteAttribute ("class", className);
}
}
else if (cssClass != null && cssClass.Length > 0) {
writer.WriteAttribute ("class", cssClass, true /* encode */);
}
}
writer.Write(">");
writer.WriteEncodedText(linkText);
writer.WriteEndTag("a");
}
示例11: ConditionalRenderLinkElement
private void ConditionalRenderLinkElement (XhtmlMobileTextWriter writer) {
if (DoesDeviceRequireCssSuppression()) {
return;
}
String cssLocation = (String) Page.ActiveForm.CustomAttributes[XhtmlConstants.StyleSheetLocationCustomAttribute];
if (cssLocation != null &&
cssLocation.Length != 0) {
writer.WriteBeginTag ("link");
writer.WriteAttribute ("type", "text/css");
writer.WriteAttribute ("rel", "stylesheet");
writer.WriteAttribute("href", cssLocation, true);
writer.WriteLine("/>");
}
else if (!writer.IsStyleSheetEmpty () && CssLocation!=StyleSheetLocation.Internal) {
writer.WriteLine ();
writer.WriteBeginTag ("link");
writer.WriteAttribute ("type", "text/css");
writer.WriteAttribute ("rel", "stylesheet");
String queryStringValue = GetCssQueryStringValue(writer);
writer.Write(" href=\"" + XhtmlConstants.CssMappedFileName + "?" + XhtmlConstants.CssQueryStringName + "=" + queryStringValue + "\"/>");
writer.WriteLine();
}
}
示例12: RenderAsInputTypeSubmit
private void RenderAsInputTypeSubmit(XhtmlMobileTextWriter writer){
ConditionalEnterStyle(writer, Style);
writer.WriteBeginTag("input");
writer.WriteAttribute("type", "submit");
writer.WriteAttribute("name", Control.UniqueID);
writer.WriteAttribute("value", Control.Text, true);
ConditionalRenderClassAttribute(writer);
ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute);
writer.Write("/>");
// ConditionalSetPendingBreak should always be called *before* ConditionalExitStyle.
// ConditionalExitStyle may render a block element and clear the pending break.
ConditionalSetPendingBreakAfterInline(writer);
ConditionalPopPhysicalCssClass(writer);
ConditionalExitStyle(writer, Style);
}
示例13: Render
/// <include file='doc\XhtmlBasicPhoneCallAdapter.uex' path='docs/doc[@for="XhtmlPhoneCallAdapter.Render"]/*' />
public override void Render(XhtmlMobileTextWriter writer)
{
ConditionalClearPendingBreak(writer);
Style style = Style;
StyleFilter filter = writer.CurrentStyleClass.GetFilter(style);
if ((filter & XhtmlConstants.Layout) != 0) {
ConditionalEnterLayout(writer, style);
}
if (Device.CanInitiateVoiceCall) {
String text = Control.Text;
String phoneNumber = Control.PhoneNumber;
if (text == null || text.Length == 0) {
text = phoneNumber;
}
writer.WriteBeginTag("a");
if ((String)Device["supportsWtai"] == "true") {
writer.Write(" href=\"wtai://wp/mc;");
}
else {
writer.Write(" href=\"tel:");
}
foreach (char ch in phoneNumber) {
if (ch >= '0' && ch <= '9' || ch == '#' || ch == '+') {
writer.Write(ch);
}
}
writer.Write("\"");
ConditionalRenderCustomAttribute(writer, XhtmlConstants.AccessKeyCustomAttribute);
String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
if (CssLocation != StyleSheetLocation.PhysicalFile) {
String className = writer.GetCssFormatClassName(style);
if (className != null) {
writer.WriteAttribute ("class", className);
}
}
else if (cssClass != null && cssClass.Length > 0) {
writer.WriteAttribute ("class", cssClass, true /* encode */);
}
writer.Write(">");
writer.WriteEncodedText(text);
writer.WriteEndTag("a");
ConditionalSetPendingBreakAfterInline(writer);
}
else {
// Format the text string based on properties
String text = String.Format(
CultureInfo.CurrentCulture,
Control.AlternateFormat,
Control.Text,
Control.PhoneNumber);
String url = Control.AlternateUrl;
// If URI specified, create a link. Otherwise, only text is displayed.
if (url != null && url.Length > 0) {
String cssClass = GetCustomAttributeValue(XhtmlConstants.CssClassCustomAttribute);
String accessKey = GetCustomAttributeValue(XhtmlConstants.AccessKeyCustomAttribute);
RenderBeginLink(writer, url, accessKey, style, cssClass);
writer.WriteEncodedText(text);
RenderEndLink(writer);
ConditionalSetPendingBreakAfterInline(writer);
}
else {
writer.WritePendingBreak();
ConditionalEnterFormat(writer, style);
ConditionalRenderOpeningSpanElement(writer);
writer.WriteEncodedText(text);
ConditionalRenderClosingSpanElement(writer);
ConditionalExitFormat(writer, style);
ConditionalSetPendingBreak(writer);
}
}
if ((filter & XhtmlConstants.Layout) != 0) {
ConditionalExitLayout(writer, style);
}
}
示例14: WriteItemValueAttribute
private void WriteItemValueAttribute (XhtmlMobileTextWriter writer, int index, String value) {
String controlFormAction = Control.Form.Action;
if (controlFormAction == null || controlFormAction.Length == 0) {
writer.WriteAttribute ("value", index.ToString(CultureInfo.InvariantCulture));
}
else {
writer.WriteAttribute ("value", value, true /*encode*/);
}
}
示例15: ConditionalRenderCustomAttribute
/// <include file='doc\XhtmlBasicControlAdapter.uex' path='docs/doc[@for="XhtmlControlAdapter.ConditionalRenderCustomAttribute1"]/*' />
protected virtual void ConditionalRenderCustomAttribute(XhtmlMobileTextWriter writer,
String attributeName, String markupAttributeName) {
String attributeValue = ((IAttributeAccessor)Control).GetAttribute(attributeName);
if (attributeValue != null && attributeValue.Length > 0) {
writer.WriteAttribute(markupAttributeName, attributeValue, true);
}
}