473,788 Members | 3,057 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do you add event handlers for controls generated with xsl?

For ASP.Net/C Sharp

I have an XML file and an associated XSL file. I am using the
System.Web.UI.C ontrols.Xml control to render the resulting HTML. This
seems to work fine with one slight drawback. I cannot seem to find a
way to attach to the events generated by controls generated by the XSL
transformation.

I have tried the FindControl on the page, but it does not find the
control. There must be something I am doing wrong because I connat
seem to find the answer.

Any assistance with this will be greatly appreciated.
=============== =============== =============== =============== ======
The following this the code that I am using:
private void Page_Load(objec t sender, System.EventArg s e)
{
XmlDocument doc = new XmlDocument();
doc.Load(Server .MapPath("XMLFi le1.xml"));

XslTransform trans = new XslTransform();
trans.Load(Serv er.MapPath("XSL TFile1.xslt"));

Xml1.Document = doc;
Xml1.Transform = trans;
}

The following is the XML file (XMLFile1.xml):
<?xml version="1.0" encoding="utf-8" ?>
<root/>
=============== =============== =============== =============== ======
The following is the XSL file (XSLFile1.xml):
<?xml version="1.0"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" />

<xsl:template match="*">
<INPUT id="submit1" name="submit1" type="button" value="Push Me"
/>
</xsl:template>
</xsl:stylesheet>
=============== =============== =============== =============== ======
Nov 12 '05 #1
1 2777
Hi,

with this glance in the stylesheet:
...
<xsl:template match="*">
<INPUT id="submit1" name="submit1" type="button" value="Push Me"
/>
</xsl:template>
....
INPUT element does not have runat="server" attribute so it is not
considered as server-side control. Also note that you need to parse the
control from the result using Page.ParseContr ol and add to the Controls
collection.

You can see this blog post for an example & related discussion:
http://weblogs.asp.net/kaevans/archi...2/22/2795.aspx

--
Teemu Keiski
MCP, Microsoft MVP (ASP.NET), AspInsiders member
ASP.NET Forum Moderator, AspAlliance Columnist

"MikeC" <mj********@hot mail.com> wrote in message
news:a9******** *************** ***@posting.goo gle.com...
For ASP.Net/C Sharp

I have an XML file and an associated XSL file. I am using the
System.Web.UI.C ontrols.Xml control to render the resulting HTML. This
seems to work fine with one slight drawback. I cannot seem to find a
way to attach to the events generated by controls generated by the XSL
transformation.

I have tried the FindControl on the page, but it does not find the
control. There must be something I am doing wrong because I connat
seem to find the answer.

Any assistance with this will be greatly appreciated.
=============== =============== =============== =============== ======
The following this the code that I am using:
private void Page_Load(objec t sender, System.EventArg s e)
{
XmlDocument doc = new XmlDocument();
doc.Load(Server .MapPath("XMLFi le1.xml"));

XslTransform trans = new XslTransform();
trans.Load(Serv er.MapPath("XSL TFile1.xslt"));

Xml1.Document = doc;
Xml1.Transform = trans;
}

The following is the XML file (XMLFile1.xml):
<?xml version="1.0" encoding="utf-8" ?>
<root/>
=============== =============== =============== =============== ======
The following is the XSL file (XSLFile1.xml):
<?xml version="1.0"?>
<xsl:styleshe et version="1.0"
xmlns:xsl="http ://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" />

<xsl:template match="*">
<INPUT id="submit1" name="submit1" type="button" value="Push Me"
/>
</xsl:template>
</xsl:stylesheet>
=============== =============== =============== =============== ======

Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
1067
by: Kevin Waite | last post by:
On many occasions (but without an obvious pattern), we (it's not just me!) encounter a problem with VS.Net losing event handlers for controls, e.g. the auto-generated this.button.click += new <handler stuff> gets dropped from InitializeComponent. The effect is that a web form that used to do something when you clicked on the button is now inert. We tried a workaround of manually setting our event handlers in a separate initialisation method...
0
2440
by: Gary Shell | last post by:
I am experiencing some strange behavior between a UserControl's validating event and a treeview control. Initially, I thought it was related to an issue in the Knowledgebase article 810852 (http://support.microsoft.com/kb/810852), but then I realized that the hotfix mentioned was in .Net v1.1, which I am using. I took the sample from that article and recreated the situation I see in my application. (Code included below.) If you run the...
9
14459
by: Marcelo Cabrera | last post by:
Hi, I have a user control that in turn creates a bunch of webcontrols dynamically and handles the events these webcontrols raise. It used to work fine on ASP .Net 1.1 but when compiled on 2.0 it does not. The problem is that the webcontrols get created on the OnLoad event of the usercontrol and the event handlers are assigned at the same time. I have to click twice on the controls for the events to be raised, the first time nothing...
5
2459
by: mayur_hirpara | last post by:
Hi, I have been developing web applications for a while now. However, as I was thinking through the architecture I really don't understand the "How server can identify between which buttons has made the postback request.???" for e.g. I have a webpage default.aspx. I place TWO or more server buttons on it. Create server-side event handlers for each of the buttons.
16
2518
by: Hamed | last post by:
Hello I am developing a utility to be reused in other programs. It I have an object of type Control (a TextBox, ComboBox, etc.) that other programmers use it in applications. they may set some of properties or assign event handlers. I need to be able to clone the manipulated control at runtime. I could use the Clone method of some objects (like Font, Style, String,
14
8640
by: Hamed | last post by:
Hello It seems that I should implement ICloneable to implement my own clone object. the critical point for me is to make a control object based on another control object that all of its event handlers are set like the old one. Is there a way to do this job? For example, is there a way to use EventInfo object to get all event handlers of the old control in runtime and set my new cloned control events to the event handlers of the old...
5
1947
by: jrett | last post by:
I'm working on a windows forms application and some of my controls have multiple event handlers assigned to them. I haven't figured out how to add multiple event handlers via the properties window, so I do it manually. However, it seems that whenever I bring up a properties window, VS removes one of my handlers, from each control that has more than one handler. Please help! How can I get this to stop?? -- Jaan
1
1680
by: kaczmar2 | last post by:
I have an ASP.NET page where controls are created dynamically, and I have an issue where one event handler creates another set of controls, and then adds event handlers to those controls. The problem comes in where I need to raise the event in the second control - the event does not fire. I have distilled the example below down to it simplest: on Page_Load one button is created, and a Click event hander is added to the button. When...
4
1974
by: Spectre1337 | last post by:
Hello, I'm having huge difficulties solving what should be a relatively trivial problem. The following is a gross simplification (obviously it's not that simple in reality) but it will serve its purpose: I need to program a dynamically generated list, kind of like a shoutbox, that stores the messages in a Profile variable. I know, I know, the messages would be lost as soon as the session expires, but that'll be sufficient for this...
2
3929
by: John Kotuby | last post by:
Hi guys, I am converting a rather complicated database driven Web application from classic ASP to ASP.NET 2.0 using VB 2005 as the programming language. The original ASP application works quite well, so at times it is tempting just to port parts of it over mostly as-is. In fact, one MSDN article I read suggested using straight HTML wherever possible to make the app more efficient and less resource demanding. On one page there are 2...
0
9498
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10172
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8993
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7517
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5398
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5535
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4069
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3670
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.