问题
I have a ShoppingCart UserControl
on MasterPage
. I have a following functionality:
User adds item to the cart. after clicking the button
"Complete Sale
" in UserControl
the page is redirected to "CustomerInfo.aspx
" and after filling the Customer information and clicking on submit which is on CustomerInfo.aspx page i want to call the "Complete Sale
" click event
of UserControl from "Customerinfo.aspx
" page.
Customerinfo.aspx.cs
protected void btnSubmit_Click(object sender, EventArgs e)
{
try
{
bool val=false;
int retVal = 0;
CustomerBiz objCust = new CustomerBiz();
objCust.FirstName = txtFirstName.Text.Trim();
objCust.LastName = txtLastName.Text.Trim();
objCust.Phone = txtPhone.Text.Trim();
objCust.Email = txtEmail.Text.Trim();
if (hdnCustomerID!=null && !string.IsNullOrEmpty(hdnCustomerID.Value) && hdnCustomerID.Value!="0")
objCust.CustomerID = Convert.ToInt32(hdnCustomerID.Value);
else
objCust.CustomerID =0;
retVal = objCust.AddCustomerInfo();
if (retVal > 0)
{
//success
UserControl uch = Page.Master.FindControl("shpCart") as UserControl;
Button lnkCheckOut=uch.FindControl("lnkCheckOut") as Button;
lnkCheckOut.Text = "Found in Customer.aspx";
//lnkCheckOut.Click += new EventHandler(lnkCheckOut.);
lnkCheckOut.Text = "You Clicked";//Here Text of button in UserControl changes but how to call the ClickEvent of this button in Customerinfo.aspx page ?
// completeBtn.Click += new EventHandler(btnSubmit_Click);
Response.Redirect("Devices.aspx", true);
}
else
{
//fail
}
}
catch (Exception ex)
{
}
}
Here the Button
text changes in UserControl
. But i am not able to call the Click event
of this button
from CustomerInfo.aspx
(ContentPage) any suggestions?
来源:https://stackoverflow.com/questions/23283922/how-to-trigger-click-event-of-a-button-in-usercontrol-from-contentpage