DotNetNewsgroup.com  
web access to complete list of Microsoft.NET newsgroups
   home   |   control panel login   |   archive  |  
 
  carried group
academic
adonet
aspnet
aspnet.announcements
aspnet.buildingcontrols
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
assignment_manager
datatools
dotnet.distributed_apps
dotnet.general
dotnet.myservices
dotnet.nternationalization
dotnet.scripting
dotnet.security
dotnet.vjsharp
dotnet.vsa
dotnet.xml
dotnetfaqs
framework
framework.clr
framework.compactframework
framework.component_services
framework.controls
framework.databinding
framework.drawing
framework.enhancements
framework.interop
framework.odbcnet
framework.performance
framework.remoting
framework.sdk
framework.setup
framework.webservices
framework.windowsforms
framework.wmi
frwk.windowsforms.designtime
lang.csharp
lang.jscript
lang.vb
lang.vb.controls
lang.vb.data
lang.vb.upgrade
lang.vc
lang.vc.libraries
  
 
start date: Sun, 5 Aug 2007 22:50:34 +0200,    posted on: microsoft.public.dotnet.framework.aspnet        back       

Thread Index
  1    Dariusz Tomo
          2    Stan SR
                 3    Dariusz Tomon
          4    Mark Rae [MVP]
                 5    Dariusz Tomon
          6    Sergey Poberezovskiy
                 7    Dariusz Tomo
                        8    Sergey Poberezovskiy
                        9    Dariusz Tomo
                        10    Sergey Poberezovskiy


ClientScript.RegisterClientScriptInclude -   
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.
Date:Sun, 5 Aug 2007 22:50:34 +0200   Author:  

Re: ClientScript.RegisterClientScriptInclude -   
Hi,

Did you try this ?

ClientScript.RegisterClientScriptBlock(this.GetType(), "swobject", 
scriptBlock);

Hth
Stan


"Dariusz Tomo"  a crit dans le message de 
news:%23pYkJJ61HHA.484@TK2MSFTNGP06.phx.gbl...

> 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.
>
> 
Date:Sun, 5 Aug 2007 23:07:27 +0200   Author:  

Re: ClientScript.RegisterClientScriptInclude -   
"Dariusz Tomo"  wrote in message 
news:%23pYkJJ61HHA.484@TK2MSFTNGP06.phx.gbl...


> I tried to change Page.GetType() to this.GetType() but without any effect.


this.GetType() is correct... However, the third argument of the 
RegisterClientScriptInclude method is, in fact, a URL - does the 
swfobject.js file exist in the same folder as the page which is trying to 
reference it...?
http://msdn2.microsoft.com/en-us/library/kx145dw2(VS.80).aspx


-- 
Mark Rae
ASP.NET MVP
http://www.markrae.net
Date:Sun, 5 Aug 2007 22:05:55 +0100   Author:  

RE: ClientScript.RegisterClientScriptInclude -   
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 Tomoñ" 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.
> 
> 
> 
Date:Sun, 5 Aug 2007 20:48:00 -0700   Author:  

Re: ClientScript.RegisterClientScriptInclude -   
ok, 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.
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.



Best Regards

Darek




Uzytkownik "Mark Rae [MVP]"  napisal w wiadomosci 
news:ugxQnR61HHA.484@TK2MSFTNGP06.phx.gbl...

> "Dariusz Tomo"  wrote in message 
> news:%23pYkJJ61HHA.484@TK2MSFTNGP06.phx.gbl...
>
>> I tried to change Page.GetType() to this.GetType() but without any 
>> effect.
>
> this.GetType() is correct... However, the third argument of the 
> RegisterClientScriptInclude method is, in fact, a URL - does the 
> swfobject.js file exist in the same folder as the page which is trying to 
> reference it...?
> http://msdn2.microsoft.com/en-us/library/kx145dw2(VS.80).aspx
>
>
> -- 
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net 
Date:Mon, 6 Aug 2007 17:43:44 +0200   Author:  

Re: ClientScript.RegisterClientScriptInclude -   
ok, 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.

Best Regards

Darek

Uzytkownik "Stan SR"  napisal w wiadomosci 
news:eeArjS61HHA.5616@TK2MSFTNGP04.phx.gbl...

> Hi,
>
> Did you try this ?
>
> ClientScript.RegisterClientScriptBlock(this.GetType(), "swobject", 
> scriptBlock);
>
> Hth
> Stan
>
>
> "Dariusz Tomo"  a crit dans le message de 
> news:%23pYkJJ61HHA.484@TK2MSFTNGP06.phx.gbl...
>> 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.
>>
>>
> 
Date:Mon, 6 Aug 2007 17:44:38 +0200   Author:  

Re: ClientScript.RegisterClientScriptInclude -   
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

Uytkownik "Sergey Poberezovskiy" 
 napisa w wiadomoci 
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.
>>
>>
>> 
Date:Mon, 6 Aug 2007 17:47:23 +0200   Author:  

Re: ClientScript.RegisterClientScriptInclude -   
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).

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 Tomoñ" 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" 
>  napisa³ 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.
> >>
> >>
> >> 
> 
> 
> 
Date:Mon, 6 Aug 2007 15:00:01 -0700   Author:  

Re: ClientScript.RegisterClientScriptInclude -   
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.


Uytkownik "Sergey Poberezovskiy" 
 napisa w wiadomoci 
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"
>>  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.
>> >>
>> >>
>> >>
>>
>>
>> 
Date:Wed, 8 Aug 2007 00:46:14 +0200   Author:  

Re: ClientScript.RegisterClientScriptInclude -   
Darek,

Your EFlashControl2 inherits WebControl and therefore can override its 
virtual methods (as you may not assume that AutoEventWireup is set to true on 
the page).
something similar to the following:

protected override void OnPreRender(EventArgs e)
{
	if (this.Page != null){
		string scriptBlock = "...";
		this.Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), ...
	}
	base.OnPreRender(e);
}

the reason I included check on whether the Page property is not empty is 
that control may not necessarily ends up rendered on the page, but sometimes 
into a stringbuilder instead.


"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" 
>  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"
> >>  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.
> >> >>
> >> >>
> >> >>
> >>
> >>
> >> 
> 
> 
> 
Date:Tue, 7 Aug 2007 16:46:29 -0700   Author:  

Google
 
Web dotnetnewsgroup.com


COPYRIGHT ?2005, EUROFRONT WORLDWIDE LTD., ALL RIGHT RESERVE  |   Contact us