|
|
|
start date: Fri, 17 Aug 2007 10:58:29 -0700,
posted on: microsoft.public.dotnet.xml
back
| Thread Index |
|
1
unknown
|
|
2
John Saunders [MVP] john.saunders at trizetto.com
|
|
3
unknown
|
|
4
unknown
|
|
5
Martin Honnen
|
|
6
Martin Honnen
|
|
7
unknown
|
|
8
unknown
|
|
9
unknown
|
Problem with transform XSL that incude asp.net controls
I have an xsl file that transforms an XML document and outputs it to
my web page.
The xsl file is also creating LinkButtons and they appear on the page.
However, I cannot get the linkbutton click event to fire for these
controls.
My page load event looks like the following:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim sbrAssemblies As New StringBuilder
sbrAssemblies.Append("<?xml version='1.0' encoding='utf-8'?>")
sbrAssemblies.Append("<assemblies>")
Dim dtAssembly As DataTable =
App_BL.Serialization.GetFullAssembly()
Dim dr As DataRow
For Each dr In dtAssembly.Rows
sbrAssemblies.Append(CStr(dr(0)))
Next
sbrAssemblies.Append("</assemblies>")
Dim doc As New XmlDocument
doc.LoadXml(sbrAssemblies.ToString())
Dim trans As New System.Xml.Xsl.XslCompiledTransform
trans.Load(Server.MapPath("Assembly.xsl"))
Dim writer As New System.IO.StringWriter
trans.Transform(doc, Nothing, writer)
Dim result As String = writer.ToString()
result = result.Replace("xmlns:asp=""remove""", "")
' Add to place holder on page
phXML.Controls.Add(Page.ParseControl(result))
End Sub
The click event I want to fire is:
Protected Sub lbnEdit_Click(ByVal sender As Object, ByVal e As
System.EventArgs)
Dim sLoc As String = ""
Try
Dim lbnEdit As LinkButton = CType(sender, LinkButton)
Dim strCommandArg As String =
CStr(lbnEdit.CommandArgument)
Dim strCommandName As String = CStr(lbnEdit.CommandName)
' Testing purposes output values to verify click event is working
Response.Write("Command name: " & strCommandName &
"<BR>Command Arg: " & strCommandArg & "<BR><BR>")
Catch ex As Exception
End Try
End Sub
Any help is greatly appreciate.
Tim
Date:Fri, 17 Aug 2007 10:58:29 -0700
Author:
|
Re: Problem with transform XSL that incude asp.net controls
wrote in message
news:1187373509.601759.20880@q4g2000prc.googlegroups.com...
>I have an xsl file that transforms an XML document and outputs it to
> my web page.
>
> The xsl file is also creating LinkButtons and they appear on the page.
> However, I cannot get the linkbutton click event to fire for these
> controls.
ASP.NET controls only exist on the server side. You are writing them to the
client! That will never work.
--
John Saunders [MVP]
Date:Fri, 17 Aug 2007 20:26:41 -0400
Author:
|
Re: Problem with transform XSL that incude asp.net controls
John,
That was my understanding of ASP.net controls as well.
However, I ran across this post
http://groups.google.com/group/microsoft.public.dotnet.xml/browse_thread/thread/a07e8a9515f4946c/2335a15f50447b9f?lnk=st&q=Problem+with+transform+XSL&rnum=4#2335a15f50447b9f
and thought I'd give it a shot as they said they were able to get it
to work with validation controls.
Tim
On Aug 17, 8:26 pm, "John Saunders [MVP]" <john.saunders at
trizetto.com> wrote:
> wrote in message
>
> news:1187373509.601759.20880@q4g2000prc.googlegroups.com...
>
> >I have an xsl file that transforms an XML document and outputs it to
> > my web page.
>
> > The xsl file is also creating LinkButtons and they appear on the page.
> > However, I cannot get the linkbutton click event to fire for these
> > controls.
>
> ASP.NET controls only exist on the server side. You are writing them to the
> client! That will never work.
> --
> John Saunders [MVP]
Date:Mon, 20 Aug 2007 05:34:35 -0700
Author:
|
Re: Problem with transform XSL that incude asp.net controls
Here's a link to the article I read as well:
http://microsoft.apress.com/asptodayarchive/72421/xslt-support-in-net
On Aug 20, 8:34 am, tim.cav...@gmail.com wrote:
> John,
>
> That was my understanding of ASP.net controls as well.
>
> However, I ran across this posthttp://groups.google.com/group/microsoft.public.dotnet.xml/browse_thr...
>
> and thought I'd give it a shot as they said they were able to get it
> to work with validation controls.
>
> Tim
>
> On Aug 17, 8:26 pm, "John Saunders [MVP]" <john.saunders at
>
>
>
> trizetto.com> wrote:
> > wrote in message
>
> >news:1187373509.601759.20880@q4g2000prc.googlegroups.com...
>
> > >I have an xsl file that transforms an XML document and outputs it to
> > > my web page.
>
> > > The xsl file is also creating LinkButtons and they appear on the page.
> > > However, I cannot get the linkbutton click event to fire for these
> > > controls.
>
> > ASP.NET controls only exist on the server side. You are writing them to the
> > client! That will never work.
> > --
> > John Saunders [MVP]- Hide quoted text -
>
> - Show quoted text -
Date:Mon, 20 Aug 2007 06:31:36 -0700
Author:
|
Re: Problem with transform XSL that incude asp.net controls
tim.cavins@gmail.com wrote:
> Dim result As String = writer.ToString()
> result = result.Replace("xmlns:asp=""remove""", "")
>
> ' Add to place holder on page
> phXML.Controls.Add(Page.ParseControl(result))
>
> End Sub
>
> The click event I want to fire is:
>
> Protected Sub lbnEdit_Click(ByVal sender As Object, ByVal e As
> System.EventArgs)
Can you show us how the string result looks that you pass to the
Page.ParseControl method?
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Date:Mon, 20 Aug 2007 15:50:39 +0200
Author:
|
Re: Problem with transform XSL that incude asp.net controls
Martin,
Here is the string that is sent.
<table class="css_Panel" width="100%" >
<tr>
<th width="200">
Type<br><asp:LinkButton id="lbnEdit308" Text="Edit"
CommandName="SA" CommandArgument="308" runat="server" />
</th>
<th width="50">Column 2</th>
<th width="110">Column 3</th>
<th width="100">Column 4</th>
</tr>
<tr>
<td>Text</td>
<td>Text</td>
<td>Text</td>
<td>Text</td>
</tr>
</table>
It is added to a place holder on one of my pages. I am using asp.net
2.0 with a master page as well if that helps.
Tim
On Aug 20, 9:50 am, Martin Honnen wrote:
> tim.cav...@gmail.com wrote:
> > Dim result As String = writer.ToString()
> > result = result.Replace("xmlns:asp=""remove""", "")
>
> > ' Add to place holder on page
> > phXML.Controls.Add(Page.ParseControl(result))
>
> > End Sub
>
> > The click event I want to fire is:
>
> > Protected Sub lbnEdit_Click(ByVal sender As Object, ByVal e As
> > System.EventArgs)
>
> Can you show us how the string result looks that you pass to the
> Page.ParseControl method?
>
> --
>
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/
Date:Mon, 20 Aug 2007 07:02:42 -0700
Author:
|
Re: Problem with transform XSL that incude asp.net controls
Martin,
Here is the actual text for the control I'm trying to create from the
transformation. The previous message left out the onclick attribute as
I was playing around with the code.
Type<br><asp:LinkButton id="lbnEdit308" Text="Edit"
CommandName="SA" CommandArgument="308" runat="server"
onclick="lbnEdit_Click" />
Tim
On Aug 20, 10:02 am, tim.cav...@gmail.com wrote:
> Martin,
>
> Here is the string that is sent.
>
> <table class="css_Panel" width="100%" >
> <tr>
> <th width="200">
> Type<br><asp:LinkButton id="lbnEdit308" Text="Edit"
> CommandName="SA" CommandArgument="308" runat="server" />
> </th>
> <th width="50">Column 2</th>
> <th width="110">Column 3</th>
> <th width="100">Column 4</th>
> </tr>
> <tr>
> <td>Text</td>
> <td>Text</td>
> <td>Text</td>
> <td>Text</td>
> </tr>
> </table>
>
> It is added to a place holder on one of my pages. I am using asp.net
> 2.0 with a master page as well if that helps.
>
> Tim
>
> On Aug 20, 9:50 am, Martin Honnen wrote:
>
>
>
> > tim.cav...@gmail.com wrote:
> > > Dim result As String = writer.ToString()
> > > result = result.Replace("xmlns:asp=""remove""", "")
>
> > > ' Add to place holder on page
> > > phXML.Controls.Add(Page.ParseControl(result))
>
> > > End Sub
>
> > > The click event I want to fire is:
>
> > > Protected Sub lbnEdit_Click(ByVal sender As Object, ByVal e As
> > > System.EventArgs)
>
> > Can you show us how the string result looks that you pass to the
> > Page.ParseControl method?
>
> > --
>
> > Martin Honnen --- MVP XML
> > http://JavaScript.FAQTs.com/- Hide quoted text -
>
> - Show quoted text -
Date:Mon, 20 Aug 2007 14:06:53 -0000
Author:
|
Re: Problem with transform XSL that incude asp.net controls
tim.cavins@gmail.com wrote:
> Here is the actual text for the control I'm trying to create from the
> transformation. The previous message left out the onclick attribute as
> I was playing around with the code.
>
>
> Type<br><asp:LinkButton id="lbnEdit308" Text="Edit"
> CommandName="SA" CommandArgument="308" runat="server"
> onclick="lbnEdit_Click" />
I am not sure what the problem is, you might want to ask in an ASP.NET
group about ParseControl and the event problem. I don't think it is
related to XSLT, I see the event handler not firing when I simply do
Ph1.Controls.Add(Page.ParseControl("<asp:LinkButton
id=\"lbnEdit308\" Text=\"Edit\" CommandName=\"SA\"
CommandArgument=\"308\" runat=\"server\" OnClick=\"lbnEdit_Click\" />"));
without any XSLT being involved.
I tried to find a solution googling but so far I have only found posts
about the same problem like e.g.
<http://forums.asp.net/p/729540/729540.aspx#729540> but no solution
other than using code to add event handlers once ParseControl gives you
a control.
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Date:Mon, 20 Aug 2007 19:11:42 +0200
Author:
|
Re: Problem with transform XSL that incude asp.net controls
Got it to work.
Placed the code in the Page Init function and after doing the
Page.ParseControl I looped through the controls of my placeholder and
added event handlers as shown below:
For Each ctl As Control In phAssembly.Controls
For i As Integer = 0 To ctl.Controls.Count - 1
If TypeOf ctl.Controls(i) Is LinkButton Then
Dim lbnEdit As LinkButton = CType(ctl.Controls(i),
LinkButton)
AddHandler lbnEdit.Click, AddressOf lbnEdit_Click
End If
Next
Next
Thanks for your time and help.
Tim
On Aug 20, 1:11 pm, Martin Honnen wrote:
> tim.cav...@gmail.com wrote:
> > Here is the actual text for the control I'm trying to create from the
> > transformation. The previous message left out the onclick attribute as
> > I was playing around with the code.
>
> > Type<br><asp:LinkButton id="lbnEdit308" Text="Edit"
> > CommandName="SA" CommandArgument="308" runat="server"
> > onclick="lbnEdit_Click" />
>
> I am not sure what the problem is, you might want to ask in an ASP.NET
> group about ParseControl and the event problem. I don't think it is
> related to XSLT, I see the event handler not firing when I simply do
> Ph1.Controls.Add(Page.ParseControl("<asp:LinkButton
> id=\"lbnEdit308\" Text=\"Edit\" CommandName=\"SA\"
> CommandArgument=\"308\" runat=\"server\" OnClick=\"lbnEdit_Click\" />"));
> without any XSLT being involved.
>
> I tried to find a solution googling but so far I have only found posts
> about the same problem like e.g.
> <http://forums.asp.net/p/729540/729540.aspx#729540> but no solution
> other than using code to add event handlers once ParseControl gives you
> a control.
>
> --
>
> Martin Honnen --- MVP XML
> http://JavaScript.FAQTs.com/
Date:Mon, 20 Aug 2007 19:56:38 -0000
Author:
|
|
|