3

how do i achieve this c# code in javascript

protected void Validate(object sender, EventArgs e)
{
    var _typeName = sender.GetType().FullName;
}

i want to add the Validate in all RadControls (telerik) and i wanna check if the sender is type of RadDatePicker

i tried this but its not working so i wanna check if what is the type name of the sender.

if (Telerik.Web.UI.RadDatePicker.isInstanceOfType(sender)) 
{
    alert("it is a datepicker");
}

thanks in advance..

Vincent Dagpin
  • 3,581
  • 13
  • 55
  • 85

2 Answers2

0

i think this is what you need

var toType = function(obj) {
  return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase()
}

.......

var theTypeIs = toType("Bresleveloper");

result will be "string"

(from here Better way to get type of a Javascript variable?)

Community
  • 1
  • 1
bresleveloper
  • 5,940
  • 3
  • 33
  • 47
0

Try using the type

type(sender); //will return you the type of control you are using

Somnath Kharat
  • 3,570
  • 2
  • 27
  • 51