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..

1

2 Answers 2

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?)

Sign up to request clarification or add additional context in comments.

2 Comments

it just returns an "object"
run this code : var toType = function(obj) { return ({}).toString.call(obj).match(/\s([a-zA-Z]+)/)[1].toLowerCase() } toType("Bresleveloper")
0

Try using the type

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

2 Comments

throws "type is not defined". Where would you get "type" from?
Jquery.type(sender)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.