question

Dikshadudi-8186 avatar image
0 Votes"
Dikshadudi-8186 asked AlbertKallal-4360 edited

how can i use Border.CornerRadius Property for specific control like radiobutton ?

I want round radiobutton border .

193633-screenshot-68.png193634-screenshot-69.png


dotnet-aspnet-generaldotnet-aspnet-webformsdotnet-aspnet-webpages
screenshot-68.png (316.6 KiB)
screenshot-69.png (1.3 MiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Viorel-1 avatar image
0 Votes"
Viorel-1 answered YijingSun-MSFT commented

I think that radio-buttons usually do not have borders.

To set the borders, try something like this:

 <style>
     .MyRadioButtons
     {
         border-radius: 4pt;
     }
 </style>
 . . .
 <asp:RadioButton ID="RadioButton1" runat="server" CssClass="MyRadioButtons" . . .

The <style> element can be placed before the repeater, to .css file, or any appropriate place. To simplify the HTML, you can move more properties to this style.

· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Actually I have already tried this,but it didn't worked because radiobutton is set to false when there is no value and in this case the radiobutton border in visible.

193666-screenshot-70.png


0 Votes 0 ·
screenshot-70.png (980.0 KiB)
AgaveJoe avatar image AgaveJoe Dikshadudi-8186 ·

Actually I have already tried this,but it didn't worked because radiobutton is set to false when there is no value and in this case the radiobutton border in visible.

Radio buttons are mutually exclusive options. These options, as explained in your other thread, should come from a data set usually a lookup table. The selected value of the radio button list is what the user selects. Rethink your design and use tools appropriately then this problem will simply go away.

RadioButtonList Class

Another option is to use standard HTML inputs so you have more control over the HTML. I mention this because it looks like you are following a CSS/JS template.


0 Votes 0 ·

Hi @Dikshadudi-8186 ,

Actually I have already tried this,but it didn't worked because radiobutton is set to false when there is no value and in this case the radiobutton border in visible.

What's your meanings? Which controls do you want to have the round border? The radiobutton is only could selected one in list.
Best regards,
Yijing Sun

0 Votes 0 ·
AgaveJoe avatar image
0 Votes"
AgaveJoe answered

Code behind

 Public Class _default3
     Inherits System.Web.UI.Page
    
     Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
         If Not Page.IsPostBack Then
             RadioButtonList1.DataSource = GetSizes()
             RadioButtonList1.DataValueField = "Id"
             RadioButtonList1.DataTextField = "Size"
             RadioButtonList1.DataBind()
         End If
     End Sub
    
     Protected Function GetSizes() As DataTable
         Dim Connectionstring As String = ConfigurationManager.ConnectionStrings("DefaultConnection").ToString()
         Dim Table As New DataTable()
    
    
         Dim queryString As String = "SELECT Id, Size
                                      FROM dbo.SizeLookup"
    
         Using conn As New SqlConnection(Connectionstring)
    
             Dim cmd As New SqlCommand(queryString, conn)
             cmd.CommandType = CommandType.Text
    
             conn.Open()
    
             Using reader As SqlDataReader = cmd.ExecuteReader()
                 Table.Load(reader)
             End Using
         End Using
    
         Return Table
     End Function
    
     Protected Sub Button1_Click(sender As Object, e As EventArgs)
         Label1.Text = "You Selected " & RadioButtonList1.SelectedValue & " " & RadioButtonList1.SelectedItem.Text
     End Sub
 End Class

SQL

 CREATE TABLE dbo.SizeLookup (
     Id                INT PRIMARY KEY IDENTITY(1,1),
     Size            VARCHAR(3),
     [Description]    VARCHAR(256)
 )
    
 INSERT INTO dbo.SizeLookup
 VALUES ('XS', 'Extra Small'),
 ('S', 'Small'),
 ('M', 'Medium'),
 ('L', 'Large'),
 ('XL', 'Extra Large')
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

AlbertKallal-4360 avatar image
0 Votes"
AlbertKallal-4360 answered AlbertKallal-4360 edited

You can add a style to a radio button.

Say, I have this listview:

197916-image.png

The radio buttons don't look all that great, so I have this style sheet:

197889-image.png

And now for the radiobutton list, I set CssClass="rMyChoice"

and now my rb becomes this:

197932-image.png


And you can tweak that radio button still. I actually send the text part of the rb some imbedded HTML with in-line (base64) graphics. And now with a similar style sheet like the above? I get this for my rb's:

197880-image.png

Each set above is a radio button list. So, in above, we see "issue".

That markup was this:

197850-image.png

And code to fill the issues radio button list was this:

RIssues.DataSource =
` Myrst("SELECT ID, IssueImage + Issue AS IssueImage2 FROM Issues ORDER BY ID", My.Settings.WebIssues)
RIssues.DataBind()



And, the above simple markup, 2 lines of database code (database driven for the choices).

And we get this:

197909-image.png


So, you can apply quite much any kind of style you want to your radio buttons - that is quite much the magic of what css can do for you. I in fact find that css can quite much achieve anything humans are able to cook up with their brains.

I don't like writing or setting up css - nasty stuff.

but, I for sure LOVE the output - and the results!!!

Note how I am not just limited to feeding the "text" of the radiobutton list JUST text - I am in above feeding the text property of the radiobutton HTML text - with imbedded graphics. So, you not even limited to display of a the default radio button (the css= hides that ).

Regards,
Albert D. Kallal (Access MVP 2003-2017)
Edmonton, Alberta Canada


image.png (75.4 KiB)
image.png (42.2 KiB)
image.png (100.1 KiB)
image.png (200.0 KiB)
image.png (15.4 KiB)
image.png (34.5 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.