all groups > asp.net building controls > july 2003 >
You're in the

asp.net building controls

group:

Button Type


Button Type Shawn B.
7/29/2003 4:55:22 PM
asp.net building controls: Greets,

The Button control is by default rendered as "Submit" type. I would like to
change it to "Button" or "Cancel" if I choose.

In the render event, I'm saying

Attributes.Item("type") = "button"

and it's rendering two "type" attributes, one for "Submit" and one for
"button"


How can I override the attribute and make sure it changes?


Thanks,
Shawn

Re: Button Type Shawn B.
7/31/2003 3:22:39 PM
I did this. Here's the results.

If I don't say base.AddAttributesToRender(writer) then the HTML stream for
that control isn't completely render (the style attribute is missing). By
the time I put the style back in the control I may as well just have
recreated the control from scratch. I may be doing something wrong?

If I do, then I get the same thing,
<intput type="button" type="submit"...



---------------
#Region "Overloads"

Protected Overrides Sub AddAttributesToRender( _
ByVal output As HtmlTextWriter _
)

If (ButtonType = ButtonTypes.Default OrElse ButtonType =
ButtonTypes.Submit) Then
output.AddAttribute("type", "submit")
Else
output.AddAttribute("type", LCase(ButtonType.ToString))
End If

MyBase.AddAttributesToRender(output)
End Sub

#End Region


Thanks,
Shawn


[quoted text, click to view]

Re: Button Type Teemu Keiski
7/31/2003 4:33:03 PM
Override the AddAttributesToRender method of your Button.

--
Teemu Keiski
MCP, Designer/Developer
Mansoft tietotekniikka Oy
http://www.mansoft.fi

AspInsiders Member, www.aspinsiders.com
ASP.NET Forums Moderator, www.asp.net
AspAlliance Columnist, www.aspalliance.com

[quoted text, click to view]

AddThis Social Bookmark Button