Hi,
How to use javasript call a method with parameters?
Codes:
WebForm1.aspx:
function Test() {
// Call 'CheckValid(string[] values)' and passing parameters to it?
}
WebForm1.aspx.cs:
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Collections;
namespace WebApplication1
{
public partial class WebForm1 : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e){
if (!IsPostBack) {}}
public void CheckValid(string[] values) {// etc...}
}
}
Thanks.

Khan Abrar AhmedPosted May 6, 2014, 8:39 AM
what error u are getting.
Ken HPosted Apr 25, 2014, 9:41 AM
Khan Abrar AhmedPosted Apr 15, 2014, 4:29 AM
if you want on click event you need to register you javascript method first.
for example
Private voit javascriptmethod(){
if (chkTillDate.Attributes["OnClick"] == null)
chkTillDate.Attributes.Add("OnClick", "return disableDateDropDowns(this,getElementById('" + txtToDay.ClientID + "'),getElementById('" + txtToMonth.ClientID + "'),getElementById('" + txtToYear.ClientID + "'));");
else
chkTillDate.Attributes["OnClick"] = "return disableDateDropDowns(this,getElementById('" + txtToDay.ClientID + "'),getElementById('" + txtToMonth.ClientID + "'),getElementById('" + txtToYear.ClientID + "'));";
}
and after in aspx page
function disableDateDropDowns(chk, ddlDay, ddlMonth, ddlYear) {
if (chk.checked == true) {
ddlDay.disabled = true;
ddlMonth.disabled = true;
ddlYear.disabled = true;
ddlDay.innerText = "";
ddlMonth.innerText = ""
ddlYear.innerText = "";
}
else {
ddlDay.disabled = false;
ddlMonth.disabled = false;
ddlYear.disabled = false;
}
Ken HPosted Apr 14, 2014, 10:17 AM
I need to trigger the client control's 'onclick' event.
Thank you.
Khan Abrar AhmedPosted Apr 13, 2014, 7:25 AM
Can you please explain more where you want to call the javascript method
for ex. any textbox validation or dropdown change event.