You need a control for the target of the postback; here's a skeleton of what I have; in the code
below, the XmlHtmlControl is my own version of the builtin Xml class (it does basically the same
thing, but it I didn't like the built in version). You should play around and see what works best
for you -- if you look at the generated source, you ought to be able to visually check the
__doPostBack calls to see if you are doing the right thing. Good luck. (I'm typing this in OE....
it's just an example).
public MyControl : Control, IPostBackEventH andler {
XmlHtmlControl XmlCtrl;
public override ControlCollecti on Controls {
get {
this.EnsureChil dControls();
return base.Controls() ;
}
}
protected override void CreateChildCont rols() {
this.Controls.C lear();
XmlCtrl = new XmlHtmlControl( );
this.Controls.A dd(XmlCtrl);
this.ChildContr olsCreated = true;
}
// in my class I'm using DataBind(); but you can do this wherever you want
public override void DataBind() {
XslTransform xslt = new XsltTransform() ;
xslt.Load(Serve r.MapPath("~/foobar.xslt"));
XmlCtrl.Transfo rm = xslt;
XmlCtrl.Documen tSource = Server.MapPath( "~/doc.xml");
string postback = this.Page.GetPo stBackClientHyp erLink(this, "ARG");
XmlCtrl.Transfo rmArgumentList. Clear();
XmlCtrl.Transfo rmArgumentList. AddParam("postb ack", "", postback);
base.DataBind() ;
}
// declare some kind of event if you want "Click"?
public void RaisePostBackEv ent(string eventArgument) {
// do something with eventArgument.. .. perhaps controls some kind of EventArgs subclass
// then call some kind of event handler or what ever...
// perhaps call a "Click" event.
}
}
"Karl Hungus" <nn*********@ho tmail.com> wrote in message
news:iu******** **********@twis ter.nyc.rr.com. ..
OK, this is good.
Im following you except for the part about the enclosing control. Im not
clear on what it's enclosing. Is it the entire transformation, or the page
or...?
Thanks,
Karl
"Scott" <no*****@this-is-extra-hotmail.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I use a XSLT to transform some XML to HTML; when I want to do a postback
inside the HTML output I include a parameter to the transform --
TransformArgume ntList.AddParam ("postback", "",
this.Page.GetPo stBackClientHyp erlink(this, "ARG"));
-- do the transform....
Then in the XSLT I construct an anchor; off the top of my head mine looks
something like
<xslt:templat e match="whatever ">
<a>
<xslt:attribu te name="href">
construct-the-href-using the param "postback"
</xslt:attribute>
</a>
</xslt:template>
Now for this to work you have to have an enclosing control that
implements IPostBackEventH andler (that's the first argument to the GetPostBackClie ntHyperLink; where the
interesting method is RaisePostBackEv ent(string eventArgument). The eventArgument is the
selector that you can use in your generated HTML to differentiate what's what (in this case it's ARG,
however in your XSLT rule you can change it to whatever you want).
I guess if you were really ambitious you could also write a page like
parser (similar to the ASCX/ASPX) that would allow you to associate a method at runtime... a lot
of work.
Scott
"Karl Hungus" <nn*********@ho tmail.com> wrote in message
news:74******** ***********@twi ster.nyc.rr.com ...
Im using an xsl transformation so its not practical to use controls in the usual way, but I would still like to call methods in my codebehind class.
usually Id just use onclick="<event Handler>" say for something like a button control
is there a way to manually call a method defined in a codebehind class, but is not called by a standard control? I looked at the __doPostBack() function that .net generates but it seemed impenetrable.
TIA
karl