Prev | Current Page 473 | Next

Rob Cameron and Dale Michalk

"Pro ASP.NET 3.5 Server Controls and AJAX Components"

Append("')) {");
// get the ASP.NET JavaScript that does a form
// postback and have this control submit it
script.Append(Page.ClientScript.GetPostBackEventReference(this, ""));
script.Append("}");
writer.AddAttribute(HtmlTextWriterAttribute.Href,
script.ToString());
CHAPTER 8 ?–  INTEGRATING CL IENT-SIDE SCRIPT 369
}
}
}
}
We override the AddAttributesToRender method so that we can change the normal href
attribute content to add a call to the JavaScript confirm method instead. Because we override
the href attribute, we use the GetPostBackEventReference method to set up postback; otherwise,
the form submission mechanism will not fire. GetPostBackEventReference obtains a reference to
a client-side script function that causes the server to post back to the page.
Because this control is inheriting from an existing WebControl, we do not need to call
Page.VerifyRenderingInServerForm, because this call is already performed by the base class
implementation of LinkButton. In the next section, we test the behavior of the ConfirmedLinkButton
and FormConfirmation server controls in the Confirm web form demonstration .aspx page.
The Confirm Web Form
The interaction between the client form submission event and the code emitted by controls to
perform JavaScript postbacks for ASP.


Pages:
461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485