the page).
this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), ...
"Dariusz Tomoñ" wrote:
> Dear Sergey,
>
> I eventually got by ... but I had to pass on my Page object as parameter to
> external class. Yes, before calling external class code I have value of Page
> object and when I call the code of the dll my Page object seems to be
> reseted to null (therefore I thought of passing it as parameter). Now it
> works but I'm wondering if there is other method ...
> I have no idea how can I invoke the code from external class using PreRender
> event. I'm doing it from within code so I have no graphical representation
> of external class and therefore I have no access to events in my VS2005.
> Can you share a snippet of code with me?
>
> My calling is like this:
> EuroAdresBasic.EFlashControl2 fleszcontrol = new EFlashControl2(Page,
> "panel", "
http://www.euroadres.pl/images/flash/" + flesz, "360", "340");
>
> And a snippet from EFlasControl2 is like below:
>
> public class EFlashControl2 : System.Web.UI.WebControls.WebControl
>
> {
>
> protected System.Web.UI.HtmlControls.HtmlGenericControl FlashObject
>
> = new System.Web.UI.HtmlControls.HtmlGenericControl("object");
>
> protected System.Web.UI.HtmlControls.HtmlGenericControl FlashParam
>
> = new System.Web.UI.HtmlControls.HtmlGenericControl("param");
>
> protected System.Web.UI.HtmlControls.HtmlGenericControl FlashEmbed
>
> = new System.Web.UI.HtmlControls.HtmlGenericControl("embed");
>
> protected System.Web.UI.HtmlControls.HtmlGenericControl pr;
>
> public EFlashControl2(Page PageObject, string layer, string path, string
> szerokosc, string wysokosc)
>
> {
>
> //Page page = new Page();
>
>
>
> Random RandomClass = new Random();
>
> int RandomNumber = RandomClass.Next(0, 90000);
>
> string SWFObjectName = RandomNumber.ToString();
>
>
>
> PageObject.ClientScript.RegisterClientScriptInclude(PageObject.GetType(),
> "swfobject.js", "swfobject.js");
>
> string scriptBlock = "<script type=\"text/javascript\"
> language=\"JavaScript\">" +
>
> "var fo = new SWFObject(\"" + path + "\", \"" + SWFObjectName + "\", \"" +
> szerokosc + "\", \"" + wysokosc + "\", \"6\", \"#FFFFFF\");" +
>
> "fo.write(\"" + layer + "\");" +
>
> "</script>";
>
> PageObject.ClientScript.RegisterClientScriptBlock(PageObject.GetType(),
> layer, scriptBlock);
>
>
>
> Best Regards
>
>
>
> Darek T.
>
>
> U¿ytkownik "Sergey Poberezovskiy"
> <SergeyPoberezovskiy@discussions.microsoft.com> napisa³ w wiadomo¶ci
> news:DE6ECBC8-36F2-4D37-9B4E-460D4D9BC173@microsoft.com...
> > Darek,
> >
> > If you have a control that resides on the page you after, then you can use
> > it's Page property. If you say that your control's Page property is null,
> > it
> > looks like you are trying to reference it too early in the control's
> > lifetime
> > (before the control is added to the page controls hierarchy).
> > ahe
> > I usually register all my scripts in PreRender event - this way you do not
> > execute unnecessary code if, say in other control's events the current
> > page
> > terminates (if Response is redirected, transferred or otherwise ended).
> >
> > "Dariusz Tomon" wrote:
> >
> >> ok, but I don't know hot to reffer to my Page object (during executing
> >> this
> >> line 'Page' is null. Other guys suggested using 'this' but 'this' is not
> >> my
> >> Page object, rather: - EuroAdresBasic.EFlashControl2, where
> >> EuroAdresBasic
> >> is namespace and EFlashControl2 is a class from within I'm trying to
> >> reffer
> >> to my Page object (Page is null)
> >> I tried to someting like that:
> >> Page page = new Page();
> >>
> >> but in reality it is not my Page where I want to inject JS so I cannot
> >> see
> >> my swf injected.
> >>
> >> The question is how to reffer to my Page from external project (the class
> >> is
> >> in external project)
> >>
> >> Best Regards
> >>
> >> Darek
> >>
> >> U?ytkownik "Sergey Poberezovskiy"
> >> <SergeyPoberezovskiy@discussions.microsoft.com> napisa3 w wiadomo?ci
> >> news:736BBF57-6E67-4431-B291-FEB0A8C3DD95@microsoft.com...
> >> > Dariusz,
> >> >
> >> > you will need to call it as follows:
> >> >
> >> > page..ClientScript.RegisterClientScriptInclude(page.GetType(), ...
> >> >
> >> > where page will be the reference to the page on which you are trying to
> >> > register your script.
> >> >
> >> >
> >> > "Dariusz Tomon" wrote:
> >> >
> >> >> Hello,
> >> >>
> >> >> I'd like to include JS from C# code (ASP.NET 2.0). I'm trying not
> >> >> directly
> >> >> from i.e. default.aspx.cs code but from a class belonging to DLL,
> >> >> which
> >> >> is
> >> >> referred in my project.
> >> >>
> >> >> The code is as follow:
> >> >>
> >> >> Page.ClientScript.RegisterClientScriptInclude(Page.GetType(),"swfobject.js","swfobject.js");
> >> >>
> >> >> string scriptBlock = "<script type=\"text/javascript\"
> >> >> language=\"JavaScript\">" +
> >> >>
> >> >> "var fo = new SWFObject(\"" + path + "\", \"\", \""+szerokosc+"\",
> >> >> \""+wysokosc+"\", \"6\", \"#FFFFFF\");" +
> >> >>
> >> >> "fo.write(\"" + layer + "\");" +
> >> >>
> >> >> "</script>";
> >> >>
> >> >> All the time I get error in the line -
> >> >> Page.ClientScript.RegisterClientScriptInclude(Page.GetType(),"swfobject.js","swfobject.js");
> >> >> telling that reference to the object is not set for object occurence
> >> >> (I
> >> >> cannot provide the error message because it's in my language - I have
> >> >> got
> >> >> polish version of Win2003Serv. At the occasion: Is it possible to
> >> >> force
> >> >> my
> >> >> environment to throw english errors not polish?).
> >> >>
> >> >>
> >> >> I tried to change Page.GetType() to this.GetType() but without any
> >> >> effect.
> >> >>
> >> >> Thank you for any suggestion.
> >> >>
> >> >> Darek T.
> >> >>
> >> >>
> >> >>
> >>
> >>
> >>
>
>