hi,
i have one web page which contains Windows Custom Control in it. Is there any way to handle the Windows Custom Control Click event on the Webpage?
Thanx in Advance
Srinivas.
Hi:
Do you mean Web User Control?
Here is an example about how to expose an eventhandler to the parent form:
in WebUserControl.ascx.cs:
public partial class WebUserControl : System.Web.UI.UserControl
{
public event System.EventHandler myClick;
protected void Page_Load(object sender, EventArgs e)
{
this.Button1.Click += myClick;
}
}
in WebUserControl.ascx:
<%@. Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %>
<asp:Button ID="Button1" runat="server" Text="Button" />
in Default.aspx:
<%@. Register TagName="A" TagPrefix="A" src="http://pics.10026.com/?src=~/WebUserControl.ascx" mce_src="~/WebUserControl.ascx" %>
........
<A:A id="A1" runat="server"></A:A>
..........
in Default.aspx.cs:
protected void Page_Load(object sender, EventArgs e)
{
..........
this.A1.myClick += new EventHandler(this.Button1_Click);
..........
}
protected void Button1_Click(object sender, EventArgs e)
{
Response.Write("From parent form");
}
Regards
hiAllen,
thanQ for ur kind reply. but i am looking for Windows Custom control click event on web page.
My problem is, i have one scanner application in ASP.NET which is using the userControl created in VB.NET windows application. When i click the scan button on the User control, it is scanning the page. Up to that it is OK. but My requirement is, i have to get the scanned data (or what ever be the data on the UserControl) in my Web application. in the user Control i have used Raise Event. That is working properly when i am using this user control in the Windows application, there i am able to get the User control click event. but it is not happening in ASP.NET web application.
Hope u got my problem.
ThankQ in advance for any help,
Srinivas.
Hi:
It's very difficult to get data in a Windows Control hosted in ASP.NET. If you have to use Windows Control in ASP.NET, you'd better let Windows Control do the processing such that there is no need for the host ASP.NET page to read data from it. It's one of the limitations to host a Windows Control in Asp.NET pages.
So, it's difficult to expose such a event handler to the host page as that in Web User Control in my previous post. I suggest you to use Web User Control if you have to handle the click event in the host page.
Regards.
Hi Allen,
Thank you for ur valuable information. I have been trying to get that event handler in the Webpage for the past 2 days. U have saved my time. but, my requirement is like that only. that's why i am planning to do that in the other way, like, i will write what ever the data in the Windows user control into a file and in the Web application i'll read the data from that file and will do the required operations. I hope that this will work for me.
once again thanx for putting efforts on clearing my problem.
Regards,
Srinivas.
0 comments:
Post a Comment