• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 563
  • Last Modified:

Rendering Complete Start and End Tags for INPUT in Custom Control

I am writing a custom button control (inherited from the ASP.NET button) that inserts SPAN tags between the tags of the rendered INPUT element.

The issue I am having is that when the control is rendered the INPUT element is always automatically closed.

<INPUT ... />

I need the INPUT to be rendered with a full start and end tag so that my SPAN element is properly placed.

<INPUT ...><SPAN ...></SPAN></INPUT>


public override void RenderBeginTag(HtmlTextWriter writer)
{
    base.RenderBeginTag(writer);
}
 
protected override void RenderContents(HtmlTextWriter writer)
{
    writer.WriteBeginTag("span");
    writer.WriteAttribute("class", this.ButtonCssClass);
    writer.Write(HtmlTextWriter.TagRightChar);
    base.RenderContents(writer);
    writer.WriteEndTag("span");
}
 
public override void RenderEndTag(HtmlTextWriter writer)
{
    base.RenderEndTag(writer);
}

Open in new window

0
hehdaddy
Asked:
hehdaddy
  • 4
  • 3
1 Solution
 
daveamourCommented:
Are span tags allowed inside input tags within html?
What is it you are actually trying to achieve?
0
 
hehdaddyAuthor Commented:
It would be rendered similar to this:  <INPUT TYPE="BUTTON" CLASS="ROUND" ...><SPAN>Button Text</SPAN></INPUT>

CSS styles and an image are used to make this a button with rounded ends.
0
 
daveamourCommented:
I see
Can you show me all of your button control code?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
hehdaddyAuthor Commented:
My button control code is just inheriting from System.Web.UI.* Button control. The three methods I listed are the only ones that deal with the rendering.

I did find an optional solution, and that was to inherit from the LinkButton control, spitting out the SPAN tags, etc., that I needed.

I am thinking that the only real solution for my question above, is to completely override the rendering methods and generate all the markup in my code.
0
 
daveamourCommented:
I don't think you are going to get this working with a button.
I tried just writing one in plain HTML to see how the browser would render it and I wrote this:
<input type="button"><span>Click Me</span></button>
And it rendered the button and the Click me came after the button.  I suspect this isn't in the html standard so maybe best to use a different control as your base control?
0
 
hehdaddyAuthor Commented:
Thanks for your help. My work in using the Link Button control worked like a charm.
0
 
daveamourCommented:
Ok thanks for the points
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now