本文整理汇总了C#中System.Web.UI.WebControls.Literal.RenderControl方法的典型用法代码示例。如果您正苦于以下问题:C# Literal.RenderControl方法的具体用法?C# Literal.RenderControl怎么用?C# Literal.RenderControl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Web.UI.WebControls.Literal
的用法示例。
在下文中一共展示了Literal.RenderControl方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Render
protected override void Render(HtmlTextWriter writer)
{
Literal itmCaption = new Literal();
itmCaption.Text = "<label for=\"" + this.ClientID + "\" class=\"" + this.CaptionCssClass + "\">" + this.Caption + "</label>";
itmCaption.RenderControl(writer);
base.Render(writer);
}
示例2: RenderBeginTag
public override void RenderBeginTag(HtmlTextWriter writer)
{
string cssClasss = "tab-pane";
if (IsActive)
{
cssClasss += " active";
}
StringBuilder sb = new StringBuilder();
sb.Append("<div role=\"tabpanel\" class=\"" + cssClasss + "\" id=\"" + this.ClientID + "\">");
sb.Append(Environment.NewLine);
Literal litBegin = new Literal();
litBegin.Text = sb.ToString();
litBegin.RenderControl(writer);
}
示例3: Render
protected override void Render(HtmlTextWriter writer)
{
IPagedCollection<MetaTag> blogMetaTags = MetaTags.GetMetaTagsForBlog(Blog, 0, int.MaxValue);
foreach(MetaTag tag in blogMetaTags)
{
var htmlMetaTag = new HtmlMeta { Content = tag.Content };
if(!string.IsNullOrEmpty(tag.Name))
{
htmlMetaTag.Name = tag.Name;
}
else
{
htmlMetaTag.HttpEquiv = tag.HttpEquiv;
}
var newLineLiteral = new Literal { Text = Environment.NewLine };
newLineLiteral.RenderControl(writer);
htmlMetaTag.RenderControl(writer);
}
}
示例4: Render
//.........这里部分代码省略.........
break;
case Enumerations.FormGroupStyle.Error:
cssGroupClass += " has-error";
break;
}
}
sb.Append("<div class=\"");
sb.Append(cssGroupClass);
sb.Append("\">");
sb.Append(Environment.NewLine);
if (!string.IsNullOrEmpty(this.Label))
{
sb.Append("<label class=\"control-label\" for=\"");
sb.Append(this.ClientID);
sb.Append("\">");
sb.Append(this.Label);
if(this.Required && !string.IsNullOrEmpty(this.RequiredIconClass))
{
sb.Append(" <i class=\"");
sb.Append(this.RequiredIconClass);
sb.Append("\"></i>");
}
sb.Append("</label>");
sb.Append(Environment.NewLine);
}
sb.Append("<div class=\"input-group date\" id=\"");
sb.Append(this.InternalId);
sb.Append("\">");
sb.Append(Environment.NewLine);
//Render the base control using a new html writer, which in turn uses a
//text writer so we can capture the html and store it in our string builder
TextWriter txtWriter = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(txtWriter);
htmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "form-control");
if (!String.IsNullOrEmpty(this.Placeholder))
{
htmlWriter.AddAttribute("placeholder", this.Placeholder);
}
if (this.State == Enumerations.States.Disabled)
{
htmlWriter.AddAttribute("disabled", "");
}
base.Render(htmlWriter);
sb.Append(txtWriter);
sb.Append(Environment.NewLine);
sb.Append("<span class=\"input-group-addon\">");
sb.Append("<span class=\"glyphicon glyphicon-calendar\"></span>");
sb.Append("</span>");
sb.Append("</div>");
sb.Append(Environment.NewLine);
if (!string.IsNullOrEmpty(this.HelpText))
{
sb.Append("<p class=\"help-block\">");
sb.Append(this.HelpText);
sb.Append("</p>");
sb.Append(Environment.NewLine);
}
sb.Append("</div>");
sb.Append(Environment.NewLine);
string linkedDtp = "null";
if (this.DateTimePickerUsedAsMax != null && !string.IsNullOrEmpty(this.DateTimePickerUsedAsMax) &&
this.Page != null)
{
var dtpControl = this.Page.FindControlRecursive(this.DateTimePickerUsedAsMax);
if (dtpControl is DateTimePickerInput)
{
linkedDtp = "$(\"#" + (dtpControl as DateTimePickerInput).InternalId + "\")";
}
else
{
throw new Exception("Error rendering DateTimePicker control: " + this.DateTimePickerUsedAsMax +
" could not be found or is not of the correct Type.");
}
}
sb.Append("<script type=\"text/javascript\">");
sb.Append("$(window).load(function() { CreateDateTimePicker($(\"#" + this.InternalId + "\"),\"" +
this.Language + "\", \"" + this.DateTimeMask + "\", " + linkedDtp + "); })");
sb.Append("</script>");
Literal litEnd = new Literal();
litEnd.Text = sb.ToString();
litEnd.RenderControl(writer);
}
示例5: RenderBeginTag
public override void RenderBeginTag(HtmlTextWriter writer)
{
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"panel panel-default\">");
sb.Append(Environment.NewLine);
sb.Append("<div class=\"panel-heading\">");
sb.Append(Environment.NewLine);
Guid gPanel = Guid.NewGuid();
//Guid gSwitch = Guid.NewGuid();
if (CreateHideButton)
{
sb.Append(this.Title);
sb.Append("<div class=\"btn-group pull-right\" style=\"margin-top: -5px\">");
bSwitch = new Switch();
bSwitch.Size = Enumerations.SwitchSize.Small;
bSwitch.Checked = !PanelIsInitiallyHidden;
bSwitch.OffText = "<i class=\"glyphicon glyphicon-remove\">";
bSwitch.OnText = "<i class=\"glyphicon glyphicon-ok\">";
this.Controls.Add(bSwitch);
TextWriter txtWriter = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(txtWriter);
bSwitch.RenderControl(htmlWriter);
sb.Append(txtWriter);
sb.Append("<script type=\"text/javascript\">");
sb.Append("$(window).load(function() {");
sb.Append("if($('#" + bSwitch.ClientID + "').attr('checked')){");
sb.Append("$('#" + gPanel + "').show();");
sb.Append("}");
sb.Append("else{");
sb.Append("$('#" + gPanel + "').hide();");
sb.Append("}");
sb.Append("});");
sb.Append("$('#" + bSwitch.ClientID + "').on('switchChange.bootstrapSwitch', function(event, state) {");
sb.Append("if(state){");
sb.Append("$('#" + gPanel + "').slideDown(500);");
sb.Append("}");
sb.Append("else{");
sb.Append("$('#" + gPanel + "').slideUp(500);");
sb.Append("}");
sb.Append("});");
sb.Append("</script>");
sb.Append("</div>");
}
else
{
sb.Append(this.Title);
}
sb.Append(Environment.NewLine);
sb.Append("</div>");
sb.Append(Environment.NewLine);
sb.Append("<div class=\"panel-body\" id=\"" + gPanel + "\">");
sb.Append(Environment.NewLine);
Literal litEnd = new Literal();
litEnd.Text = sb.ToString();
litEnd.RenderControl(writer);
}
示例6: Render
protected override void Render(HtmlTextWriter writer)
{
string cssClass = "alert ";
switch (AlertStyle)
{
case Enumerations.AlertStyle.Info:
cssClass += "alert-info";
break;
case Enumerations.AlertStyle.Error:
cssClass += "alert-danger";
break;
case Enumerations.AlertStyle.Success:
cssClass += "alert-success";
break;
case Enumerations.AlertStyle.Warning:
cssClass += "alert-warning";
break;
}
StringBuilder sb = new StringBuilder();
sb.Append("<div class=\"");
sb.Append(cssClass);
sb.Append("\"");
sb.Append(" id=\"");
sb.Append(this.ClientID);
sb.Append("\"");
sb.Append(" role =\"alert\">");
if (!string.IsNullOrEmpty(this.ImageClass))
{
sb.Append("<span class=\"");
sb.Append(this.ImageClass);
sb.Append("\" aria-hidden=\"true\"></span>");
}
sb.Append("<span class=\"sr-only\">");
sb.Append(this.Title);
sb.Append("</span>");
sb.Append(" ");
sb.Append(this.Text.Trim());
sb.Append("</div>");
Literal litEnd = new Literal();
litEnd.Text = sb.ToString();
litEnd.RenderControl(writer);
}
示例7: RenderBeginTag
//.........这里部分代码省略.........
}
sb.Append("</label>");
sb.Append(Environment.NewLine);
}
string imagePreviewId = Guid.NewGuid().ToString("N");
sb.Append("<div class=\"input-group\" id=\""+ imagePreviewId + "\">");
sb.Append("<input type=\"text\" class=\"form-control\" id=\"" + imagePreviewId + "-filename\" disabled=\"disabled\">");
sb.Append("<span class=\"input-group-btn\">");
sb.Append("<button type=\"button\" class=\"btn btn-default\" id=\"" + imagePreviewId + "-clear\" style=\"display: none;\">");
sb.Append("<span class=\"glyphicon glyphicon-remove\"></span> Clear");
sb.Append("</button > ");
//style=\"position: relative; overflow: hidden; margin: 0px; color: #333; background-color: #fff; border-color: #ccc;\"
sb.Append("<div class=\"btn btn-default\" id=\"" + imagePreviewId + "-input\">");
sb.Append("<span class=\"glyphicon glyphicon-folder-open\"></span>");
sb.Append("<span id=\"" + imagePreviewId + "-input-title\" style=\"margin-left: 2px;\"> Browse</span>");
string closeButtonId = Guid.NewGuid().ToString("N");
sb.Append(Environment.NewLine);
sb.Append("<script>");
sb.Append(Environment.NewLine);
sb.Append(@"$(document).on('click', '#" + closeButtonId + @"', function () {
$('#" + imagePreviewId + @"').popover('hide');
$('#" + imagePreviewId + @"').hover(
function() {
$('#" + imagePreviewId + @"').popover('show');
},
function() {
$('#" + imagePreviewId + @"').popover('hide');
}
);
});"
);
sb.Append(Environment.NewLine);
sb.Append(@"$(function() {
// Create the close button
var closebtn = $('<button/>', {
type: ""button"",
text: 'x',
id: '" + closeButtonId + @"',
style: 'font-size: initial;',
});
closebtn.attr(""class"", ""close pull-right"");
// Set the popover default content
$('#" + imagePreviewId + @"').popover({
trigger: 'manual',
html: true,
title: ""<strong>Preview</strong>"" + $(closebtn)[0].outerHTML,
content: ""There's no image"",
placement: 'bottom'
});
// Clear event
$('#" + imagePreviewId + @"-clear').click(function () {
$('#" + imagePreviewId + @"').attr(""data-content"", """").popover('hide');
$('#" + imagePreviewId + @"-filename').val("""");
$('#" + imagePreviewId + @"-clear').hide();
$('#" + imagePreviewId + @"-input input:file').val("""");
$('#" + imagePreviewId + @"-input-title').text(""Browse"");
});
// Create the preview image
$('#" + imagePreviewId + @"-input input:file').change(function () {
var img = $('<img/>', {
id: 'dynamic',
width: '250',
height: 'auto'
});
var file = this.files[0];
var reader = new FileReader();
// Set preview image into the popover data-content
reader.onload = function(e) {
$('#" + imagePreviewId + @"-title').text(""Change"");
$('#" + imagePreviewId + @"-clear').show();
$('#" + imagePreviewId + @"-filename').val(file.name);
img.attr('src', e.target.result);
$('#" + imagePreviewId + @"').attr('data-content', $(img)[0].outerHTML).popover('show');
}
reader.readAsDataURL(file);
});
});
");
sb.Append("</script>");
var litEnd = new Literal();
litEnd.Text = sb.ToString();
litEnd.RenderControl(writer);
}
示例8: RenderEndTag
public override void RenderEndTag(HtmlTextWriter writer)
{
StringBuilder sb = new StringBuilder();
sb.Append("</div>");
sb.Append("</span>");
sb.Append("</div>");
sb.Append("</div>");
var litEnd = new Literal();
litEnd.Text = sb.ToString();
litEnd.RenderControl(writer);
}
示例9: Render
protected override void Render(HtmlTextWriter writer)
{
//This will hold all the HTML we want to write as output.
StringBuilder sb = new StringBuilder();
//Holds the group class(es)
string cssGroupClass = "form-group";
if (!this.IsValid()) //Call the extention method in base to see if this control is valid
{
cssGroupClass += " has-error";
}
sb.Append("<div class=\"");
sb.Append(cssGroupClass);
sb.Append("\">");
sb.Append(Environment.NewLine);
if (!string.IsNullOrEmpty(this.Label))
{
sb.Append("<label class=\"control-label\" for=\"");
sb.Append(this.ClientID);
sb.Append("\">");
sb.Append(this.Label);
if (this.Required && !string.IsNullOrEmpty(this.RequiredIconClass))
{
sb.Append(" <i class=\"");
sb.Append(this.RequiredIconClass);
sb.Append("\"></i>");
}
sb.Append("</label>");
sb.Append(Environment.NewLine);
}
//Render the base control using a new html writer, which in turn uses a
//text writer so we can capture the html and store it in our string builder
TextWriter txtWriter = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(txtWriter);
string cssSelectClass = "form-control";
if (AddChznClass)
{
cssSelectClass += " chzn-select";
}
htmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, cssSelectClass);
//If we have a placeholder and its a "chosen" dropdown, remove the text from the first item
//Item is added when setting the placeholder property.
if (!string.IsNullOrEmpty(this.Placeholder))
{
ListItem listItem = new ListItem(this.Placeholder, "");
listItem.Attributes.Add("disabled", null);
this.Items.Insert(0, listItem);
if (AddChznClass)
{
htmlWriter.AddAttribute("data-placeholder", this.Placeholder);
this.Items[0].Text = "";
}
}
base.Render(htmlWriter);
sb.Append(txtWriter);
sb.Append(Environment.NewLine);
if (!string.IsNullOrEmpty(this.HelpText))
{
sb.Append("<p class=\"help-block\">");
sb.Append(this.HelpText);
sb.Append("</p>");
sb.Append(Environment.NewLine);
}
sb.Append("</div>");
sb.Append(Environment.NewLine);
if (AddChznClass)
{
sb.Append("<script type=\"text/javascript\">");
sb.Append("$(window).load(function() { ");
sb.Append("$(\"#" + this.ClientID + "\").chosen({allow_single_deselect: true});");
sb.Append(" })");
sb.Append("</script>");
}
Literal litEnd = new Literal();
litEnd.Text = sb.ToString();
litEnd.RenderControl(writer);
}
示例10: Render
protected override void Render(HtmlTextWriter writer)
{
Literal lit = new Literal();
lit.Text = RenderRating();
if (Enabled)
{
CallBackContent cbContent = new CallBackContent();
cbContent.Controls.Add(lit);
cb.Content = cbContent;
cb.RenderControl(writer);
}
else
{
lit.RenderControl(writer);
}
}
示例11: Render
public void Render ()
{
StringWriter sw = new StringWriter ();
HtmlTextWriter tw = new HtmlTextWriter (sw);
Literal l = new Literal ();
l.Text = "foobar";
l.RenderControl (tw);
Assert.AreEqual (sw.ToString (), "foobar", "A1");
}
示例12: RenderNext
private void RenderNext(HtmlTextWriter writer)
{
if (this.HasNext)
{
Literal literal = new Literal();
literal.Text = " ";
literal.RenderControl(writer);
this.nextButton.RenderControl(writer);
}
}
示例13: Render
//.........这里部分代码省略.........
if (!string.IsNullOrEmpty(this.PrefixText))
{
sb.Append(this.PrefixText);
}
else if (!string.IsNullOrEmpty(this.PrefixImageClass))
{
sb.Append("<i class=\"");
sb.Append(this.PrefixImageClass);
sb.Append("\"></i>");
}
sb.Append("</span>");
sb.Append(Environment.NewLine);
}
}
if (this.State == Enumerations.States.Static)
{
sb.Append("<p class=\"form-control-static\" ");
sb.Append("name=\"");
sb.Append(this.ClientID);
sb.Append("\" id=\"");
sb.Append(this.ClientID);
sb.Append("\">");
sb.Append(this.Text);
sb.Append("</p>");
sb.Append(Environment.NewLine);
}
else
{
//Render the base control using a new html writer, which in turn uses a
//text writer so we can capture the html and store it in our string builder
TextWriter txtWriter = new StringWriter();
HtmlTextWriter htmlWriter = new HtmlTextWriter(txtWriter);
htmlWriter.AddAttribute(HtmlTextWriterAttribute.Class, "form-control");
if (!String.IsNullOrEmpty(this.Placeholder))
{
htmlWriter.AddAttribute("placeholder", this.Placeholder);
}
if(this.TagInput)
{
htmlWriter.AddAttribute("data-role", "tagsinput");
}
if (this.State == Enumerations.States.Disabled)
{
htmlWriter.AddAttribute("disabled", "");
}
base.Render(htmlWriter);
sb.Append(txtWriter);
sb.Append(Environment.NewLine);
}
// Should I render an inner group (used to close it if it was started) ...
if (renderInnerGroup)
{
if (renderPostix) //Before closing the inner group, should I write a postfix ...
{
sb.Append("<span class=\"input-group-addon\">");
if (!string.IsNullOrEmpty(this.PostfixText))
{
sb.Append(this.PostfixText);
}
else if (!string.IsNullOrEmpty(this.PostfixImageClass))
{
sb.Append("<i class=\"");
sb.Append(this.PostfixImageClass);
sb.Append("\"></i>");
}
sb.Append("</span>");
sb.Append(Environment.NewLine);
}
sb.Append("</div>");
sb.Append(Environment.NewLine);
}
if (!string.IsNullOrEmpty(this.HelpText))
{
sb.Append("<p class=\"help-block\">");
sb.Append(this.HelpText);
sb.Append("</p>");
sb.Append(Environment.NewLine);
}
sb.Append("</div>");
sb.Append(Environment.NewLine);
Literal litEnd = new Literal();
litEnd.Text = sb.ToString();
litEnd.RenderControl(writer);
}
示例14: Render
// -------------------------------------------------------------------------------------
/// <summary>
/// Render this control to the output parameter specified.
/// </summary>
/// <param name="output"> The HTML writer to write out to </param>
// -------------------------------------------------------------------------------------
protected override void Render(HtmlTextWriter output)
{
if (m_Question == null)
{
output.Write("Set question properties");
return;
}
ChildControlsCreated = false;
EnsureChildControls();
// --- Render text controls
if (m_ControlState == ControlState.ReadOnly)
{
Literal answer = new Literal();
answer.Text = "<b>" + m_Question.Answer + "</b>";
answer.RenderControl(output);
}
else
{
// validation
string mandatory = string.Empty;
string validationError = string.Empty;
if ((m_Question.QuestionConstraint != null) && (m_Question.QuestionConstraint.Mandatory))
{
mandatory = "!";
}
if (ValidationSummary != string.Empty)
{
validationError = "*";
}
string validationText =
string.Format(" {0} {1} ", mandatory, validationError);
Label validation = new Label();
validation.CssClass = "ValidationSummary";
validation.Text = validationText;
validation.RenderControl(output);
// delegate the actual rendering to baseclass
base.Render(output);
}
}
示例15: Render
// -------------------------------------------------------------------------------------
/// <summary>
/// Render this control to the output parameter specified.
/// </summary>
/// <param name="output"> The HTML writer to write out to </param>
// -------------------------------------------------------------------------------------
protected override void Render(HtmlTextWriter output)
{
if (m_Question == null)
{
output.Write("Set question properties");
return;
}
// these two call's are needed to show the control at design time
ChildControlsCreated = false;
EnsureChildControls();
// --- Render text controls
if (m_ControlState == ControlState.ReadOnly)
{
Literal answer = new Literal();
foreach (QuestionListItem item in m_Question.QuestionItemList)
{
if (item.ItemName.ToString() == m_Question.Answer.ToString())
{
answer.Text = answer.Text + "<li><b>" + item.ItemName + "</b><br>";
}
else
{
answer.Text = answer.Text + "<li>" + item.ItemName + "<br>";
}
}
answer.RenderControl(output);
}
else
{
// validation
string mandatory = string.Empty;
string validationError = string.Empty;
if ((m_Question.QuestionConstraint != null) && (m_Question.QuestionConstraint.Mandatory))
{
mandatory = "!";
}
if (ValidationSummary != string.Empty)
{
validationError = "*";
}
string validationText =
string.Format(" {0} {1} ", mandatory, validationError);
Label validation = new Label();
validation.CssClass = "ValidationSummary";
validation.Text = validationText;
validation.RenderControl(output);
// delegate the actual rendering to baseclass
base.Render(output);
}
}