In a Usercontrol which control triggered postback event
-
In a ordinary web form Iam able to find out which control triggered postback event using Determinepostbackmode method. In a usercontrol i need to find out which control triggered postback event. I dont find any method called determinepostmode in usercontrol. Can anyone help out with this. Padvit
-
In a ordinary web form Iam able to find out which control triggered postback event using Determinepostbackmode method. In a usercontrol i need to find out which control triggered postback event. I dont find any method called determinepostmode in usercontrol. Can anyone help out with this. Padvit
Hi there, The
DeterminePostBackMode
is a protected virtual method of the Page class, so you can call this method inside your web page which inherits from the Page class. However, in a user control you are only allowed to access the public properties and method of the Page class via the Page property of the control. If you want to use this method, you can simply create your own method which has the same logic with the help of theHttpContext
object.private NameValueCollection ControlDeterminePostBackMode()
{
if (string.Compare(HttpContext.Current.Request.HttpMethod, "POST", false, CultureInfo.InvariantCulture) == 0)
{
return HttpContext.Current.Request.Form;
}return HttpContext.Current.Request.QueryString;
}For more information, see the Page.DeterminePostBackMode Method[^] Just curious, why do you need to do this as I saw a similar question which was already answered by Brian?
-
Hi there, The
DeterminePostBackMode
is a protected virtual method of the Page class, so you can call this method inside your web page which inherits from the Page class. However, in a user control you are only allowed to access the public properties and method of the Page class via the Page property of the control. If you want to use this method, you can simply create your own method which has the same logic with the help of theHttpContext
object.private NameValueCollection ControlDeterminePostBackMode()
{
if (string.Compare(HttpContext.Current.Request.HttpMethod, "POST", false, CultureInfo.InvariantCulture) == 0)
{
return HttpContext.Current.Request.Form;
}return HttpContext.Current.Request.QueryString;
}For more information, see the Page.DeterminePostBackMode Method[^] Just curious, why do you need to do this as I saw a similar question which was already answered by Brian?
hi there Thank you very much. I always get answer from you for all of my question. One point for clarification. Do I need to declare this method in my usercontrol and call the same in pageload of the usercontrol. Iam on the busy schedule I didnt have time to got through questions. Padvit
-
hi there Thank you very much. I always get answer from you for all of my question. One point for clarification. Do I need to declare this method in my usercontrol and call the same in pageload of the usercontrol. Iam on the busy schedule I didnt have time to got through questions. Padvit
-
You can declare that method as a normal method in your user control, then make a call in the Page_load event. Or you can put it in a common class which can be shared across controls.