Note that there are some explanatory texts on larger screens.

plurals
  1. POHow can I call a function in code behind file in ASP.NET?
    text
    copied!<p>I have <code>ShowValue</code> working. Now, on the last line I need to call the function <code>newFunction</code> to repopulate the <code>dropdownlist</code> object on the <code>onClick</code> event.</p> <p>I am getting errors when I click the <code>dropdownlist</code> down arrow. </p> <p>How do I get the two to hand shake with each other?</p> <p>My code:</p> <pre><code>Public Sub ShowValue(ByVal sender As Object, ByVal e As System.EventArgs) lblupdatePanel.Text = DropDownList1.SelectedValue.ToString Dim LocationDescription2 As DropDownList = CType(dvContact.FindControl("LocationDescription2"), DropDownList) Dim LocationLogic As New LocationBLL LocationDescription2.DataSource = LocationLogic.GetUnitByUnitID(DropDownList1.SelectedValue.ToString) LocationDescription2.DataTextField = "LocationDescription" LocationDescription2.DataValueField = "LocationCode" LocationDescription2.SelectedValue = DropDownList1.SelectedValue.ToString LocationDescription2.DataBind() LocationDescription2.Attributes.Add("onclick", "newFunction(what to put here?);") End Sub Public Sub newFunction(ByVal sender As Object, ByVal e As System.EventArgs) Dim LocationDescription2 As DropDownList = CType(dvContact.FindControl("LocationDescription2"), DropDownList) Dim DivisionDescription1 As DropDownList = CType(dvContact.FindControl("DivisionDescription1"), DropDownList) Dim LocationLogic As New LocationBLL LocationDescription2.DataSource = LocationLogic.GetLocationByDivisionCode(DivisionDescription1.SelectedValue.ToString) LocationDescription2.DataTextField = "LocationDescription" LocationDescription2.DataValueField = "LocationCode" LocationDescription2.DataBind() End Sub </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload