Last post May 09, 2021 02:28 AM by sking
May 09, 2021 01:58 AM|sking|LINK
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"
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?
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?
May 09, 2021 02:28 AM|sking|LINK
OK, I figured out what works is to just have 2 buttons on the page. Both have their Onclick events and I just make one of the invisible.