Converting any Color to their's corresponding Hexa-Decimal value using Asp.Net.

Posted by vishalneeraj-24503 under ASP.NET category on | Points: 40 | Views : 513
Write below code:-
Import System.Drawing Namespace at the top of .VB page
Imports System.Drawing

Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Response.Write(ConvertColorCodeToHexColor(Color.Pink)+ "<br/>")
Response.Write(ConvertColorCodeToHexColor(Color.Blue)+ "<br/>")
Response.Write(ConvertColorCodeToHexColor(Color.Red)+ "<br/>")
Response.Write(ConvertColorCodeToHexColor(Color.Yellow)+ "<br/>")
End Sub

Function ConvertColorCodeToHexColor(ByVal clr As Color) As String
Return "#" + clr.ToArgb().ToString("x").Substring(2)
End Function


So,we can convert any Color into their Hex Value.

Comments or Responses

Login to post response