मैं दो बटन:किस नियंत्रण ने पोस्टबैक का कारण बनाया?
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:Button ID="Button2" runat="server" Text="Button" />
मैं Pageload पर कैसे निर्धारित कर सकते हैं जो इस दो में से एक की वजह से पोस्टबैक? क्या कोई छोटा समाधान है क्योंकि मुझे पता है कि केवल दो नियंत्रण हैं जो इस पोस्टबैक का कारण बन सकते हैं?
/// <summary>
/// Retrieves the control that caused the postback.
/// </summary>
/// <param name="page"></param>
/// <returns></returns>
private Control GetControlThatCausedPostBack(Page page)
{
//initialize a control and set it to null
Control ctrl = null;
//get the event target name and find the control
string ctrlName = page.Request.Params.Get("__EVENTTARGET");
if (!String.IsNullOrEmpty(ctrlName))
ctrl = page.FindControl(ctrlName);
//return the control to the calling method
return ctrl;
}
http://aspnetnova.blogspot.com/2009/04/find-post-back-co ntrol-in-aspnet-page-c.html –