Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Possible to call c# functions from within Javasript code?

Status
Not open for further replies.

josedeman

Programmer
Jan 20, 2004
23
NL
I have a piece of Javascript in my asp page that checks a checkbox on my screen. The problem is the checkedChanged method of that checkbox doesn't fire. So I wondered if I could call the checkedChanged method of that checkbox (C# function) from within my piece of Javascript code?
 
>>checkedChanged

in Html we use onClick or onChange...

Known is handfull, Unknown is worldfull
 
I have done this using asp.net (VB)....it sends the attributes of a button click to the client side...

Code:
Dim sb1 As New System.Text.StringBuilder
sb1.Append("if (typeof(Page_ClientValidate) == 'function') { ")
sb1.Append("if (Page_ClientValidate() == false) { return false; }} ")
sb1.Append("this.disabled = true;")
sb1.Append("if (true == true){")
sb1.Append("this.value = 'Sending period dates...';")
sb1.Append(Me.Page.GetPostBackEventReference(Me.btnSendMeDates))
sb1.Append(";} else {")
sb1.Append("this.disabled = false;return false;}")
Me.btnSendMeDates.Attributes.Add("onclick", sb1.ToString)
sb1 = Nothing

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
this is the key line to reference the code behind sub
Me.Page.GetPostBackEventReference(Me.btnSendMeDates))

"...we both know I'm training to become a cagefighter...see what happens if you try 'n hit me..."
 
>>GetPostBackEventReference

is equal to click=Function in control's tag huh???

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top