I have created a custom TextBox control which also contains a RequiredFieldValidator. Everything works fine but the problem is in display. The display is something like this:
[TextBox Control] [Validation Error Message]
I want the display to be something like this: (the validation error message should be at the top of the textbox)
[Validation Error Messsage] [TextBox Control]
My control inherits from the TextBox control. How can I create the display like above. I tried to use the Table control and insert TextBox and Validation control inside the Table but it gave me some sort of stack over flow error.
Here is the code:
protected override void Render(System.Web.UI.HtmlTextWriter writer) { base.Render(writer); if(_req != null) _req.RenderControl(writer); }
You’re really close to doing it right! Try this:
That will render the validation control before your TextBox instead of afterwards. If you want to change the appearance further then css is probably the way to go.