User-1767698477 posted
The text of the button says Update when the popup is being used to edit the record. Rather than repeat the same popup code on the page for the insert feature, I'm trying to use the same popup code and made 2 changes as you can see below:
Protected Sub insertbtn_Click(ByVal sender As Object, ByVal e As ImageClickEventArgs)
'blank out all fields
btnUpdate.Text = "Add"
btnUpdate.OnClientClick = "btnInsert_Click"
Me.ModalPopupExtender1.Show()
End Sub
When I click this, the popup appears with all the fields blank. (most of the time,though sometimes it doesn't)
At the bottom of the popup code is the Update button. The first change works which is changing the text from Update to Add on the button of the popup which is the click event. I looked at the source of the page and it is changing the Onclick
event to btnInsert.click as well. When I click the Add button on the popup, the breakpoint I placed is shown in yellow at btnUpdate_Click. It should be going to btnInsert_Click event. Why is this not happening?
<input type="submit" name="ctl00$ContentPlaceHolder2$btnUpdate"
value="Add" onclick="btnInsert_Click;WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ContentPlaceHolder2$btnUpdate", "", true, "", "",
false, false))" id="ctl00_ContentPlaceHolder2_btnUpdate" />
I'm looking in the intellisense and it appears there is only btnUpdate.OnClientClick available. In the aspx page the button is coded as OnClick. Why is Onclick not available in the intelliense because apparantely this is something different and is
not recognized.
I read this:
<div>OnClick will work on
server side , </div> <div> </div> <div>OnClientClick
will execute on client side before control passed to server or C# code</div>
So if I can't use Onclick in the code behind, how am I supposed to tell the control to go to btnInsert_Click sub when clicked?