Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Fri, 29 Aug 2008 09:58:07 -0400,    group: microsoft.public.dotnet.framework.aspnet        back       


Convert vb to javascript?   
I have a .htm file that shows in an iframe which is part of a master's 
asp:Content.

I need the .htm to copy the style class from the master or set it as shown 
below.

Below is how I set the stylesheet in the master.


What I'd like to do, is change that code into javascript and run it in the 
htm file.
I can change the Select into if...else

But I don't know how to is extract from Session("StyleSheetIndex"); rather 
that set it
And all the rest!

Can this be done on javascript?

Can you get me started?

Thanks for any help at all


Session("StyleSheetIndex") = colorIndex



Dim objCSS As HtmlLink = New HtmlLink()

Select Case colorIndex

Case Is = 0, 1

objCSS.Attributes.Add("href", "App_Themes/Backgroundblack.css") ' 
Session["Stylesheet"].ToString())

Case Is = 2

objCSS.Attributes.Add("href", "App_Themes/Backgroundwhite.css")

Case Is = 3

objCSS.Attributes.Add("href", "App_Themes/Backgroundtextured.css")

End Select

objCSS.Attributes.Add("rel", "stylesheet")

objCSS.Attributes.Add("type", "text/css")

HeadMaster.Controls.Add(objCSS)
date: Fri, 29 Aug 2008 09:58:07 -0400   author:   _Who

Re: Convert vb to javascript?   
"_Who"  wrote in message 
news:%23UUtE9dCJHA.4576@TK2MSFTNGP05.phx.gbl...

> I have an .htm file that shows in an iframe which is part of a master's 
> asp:Content.
>
> But I don't know how to extract from Session("StyleSheetIndex"); rather 
> than set it. And all the rest!
>
> Can this be done in JavaScript?

No. JavaScript is client-side - it can't interrogate Session variables 
because Session is server-side...


-- 
Mark Rae
ASP.NET MVP
http://www.markrae.net
date: Fri, 29 Aug 2008 15:15:18 +0100   author:   Mark Rae [MVP]

Re: Convert vb to javascript?   
Isn't there a way around that. Maybe do save something additional when I 
save the session varable that will be available on the client side.

What about the rest of the code. Is it possible to convert that to 
javascript?

Thanks



Dim objCSS As HtmlLink = New HtmlLink()

Select Case colorIndex

Case Is = 0, 1

objCSS.Attributes.Add("href", "App_Themes/Backgroundblack.css") '
Session["Stylesheet"].ToString())

Case Is = 2

objCSS.Attributes.Add("href", "App_Themes/Backgroundwhite.css")

Case Is = 3

objCSS.Attributes.Add("href", "App_Themes/Backgroundtextured.css")

End Select

objCSS.Attributes.Add("rel", "stylesheet")

objCSS.Attributes.Add("type", "text/css")

HeadMaster.Controls.Add(objCSS)



"Mark Rae [MVP]"  wrote in message 
news:eXKHtGeCJHA.2480@TK2MSFTNGP02.phx.gbl...
> "_Who"  wrote in message 
> news:%23UUtE9dCJHA.4576@TK2MSFTNGP05.phx.gbl...
>
>> I have an .htm file that shows in an iframe which is part of a master's 
>> asp:Content.
>>
>> But I don't know how to extract from Session("StyleSheetIndex"); rather 
>> than set it. And all the rest!
>>
>> Can this be done in JavaScript?
>
> No. JavaScript is client-side - it can't interrogate Session variables 
> because Session is server-side...
>
>
> -- 
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
date: Fri, 29 Aug 2008 10:54:28 -0400   author:   _Who

Re: Convert vb to javascript?   
your javascript coudl make an ajax call to get the session value, then add a 
css rule, but why bother. why don't you convert the html page to aspx, or map 
.htm to asp.net so you can set the theme.

-- bruce (sqlwork.com)


"_Who" wrote:

> Isn't there a way around that. Maybe do save something additional when I 
> save the session varable that will be available on the client side.
> 
> What about the rest of the code. Is it possible to convert that to 
> javascript?
> 
> Thanks
> 
> 
> 
> Dim objCSS As HtmlLink = New HtmlLink()
> 
> Select Case colorIndex
> 
> Case Is = 0, 1
> 
> objCSS.Attributes.Add("href", "App_Themes/Backgroundblack.css") '
> Session["Stylesheet"].ToString())
> 
> Case Is = 2
> 
> objCSS.Attributes.Add("href", "App_Themes/Backgroundwhite.css")
> 
> Case Is = 3
> 
> objCSS.Attributes.Add("href", "App_Themes/Backgroundtextured.css")
> 
> End Select
> 
> objCSS.Attributes.Add("rel", "stylesheet")
> 
> objCSS.Attributes.Add("type", "text/css")
> 
> HeadMaster.Controls.Add(objCSS)
> 
> 
> 
> "Mark Rae [MVP]"  wrote in message 
> news:eXKHtGeCJHA.2480@TK2MSFTNGP02.phx.gbl...
> > "_Who"  wrote in message 
> > news:%23UUtE9dCJHA.4576@TK2MSFTNGP05.phx.gbl...
> >
> >> I have an .htm file that shows in an iframe which is part of a master's 
> >> asp:Content.
> >>
> >> But I don't know how to extract from Session("StyleSheetIndex"); rather 
> >> than set it. And all the rest!
> >>
> >> Can this be done in JavaScript?
> >
> > No. JavaScript is client-side - it can't interrogate Session variables 
> > because Session is server-side...
> >
> >
> > -- 
> > Mark Rae
> > ASP.NET MVP
> > http://www.markrae.net 
> 
> 
>
date: Fri, 29 Aug 2008 08:18:00 -0700   author:   bruce barker

Re: Convert vb to javascript?   
"_Who"  wrote in message 
news:%23FF8jceCJHA.4576@TK2MSFTNGP05.phx.gbl...

[please don't top-post]

>>> I have an .htm file that shows in an iframe which is part of a master's 
>>> asp:Content.
>>>
>>> But I don't know how to extract from Session("StyleSheetIndex"); rather 
>>> than set it. And all the rest!
>>>
>>> Can this be done in JavaScript?
>>
>> No. JavaScript is client-side - it can't interrogate Session variables 
>> because Session is server-side...
>
> Isn't there a way around that.

Not while you're using an HTML file. HTML files are not processed by 
ASP.NET - they are simply streamed to the client...

> Maybe do save something additional when I save the session variable that 
> will be available on the client side.

I don't know how else to explain this to you - JavaScript runs on the 
client. This means it can't interact with the server. Once a piece of 
JavaScript has been streamed down to the client browser, the server has no 
further control over it...

You could, perhaps, look at saving the Session variable as a cookie and then 
retrieving it with JavaScript:
http://www.google.co.uk/search?sourceid=navclient&hl=en-GB&ie=UTF-8&rlz=1T4GZEZ_en-GBGB252GB252&q=JavaScript+cookie

> What about the rest of the code. Is it possible to convert that to 
> JavaScript?

Server-side code is server-side code and client-side code is client-side 
code... You cannot convert from one to the other, as they both run 
completely separately one from the other...


-- 
Mark Rae
ASP.NET MVP
http://www.markrae.net
date: Fri, 29 Aug 2008 16:20:13 +0100   author:   Mark Rae [MVP]

Re: Convert vb to javascript?   
"Mark Rae [MVP]"  wrote in message 
news:OAF8%23qeCJHA.5196@TK2MSFTNGP04.phx.gbl...
> "_Who"  wrote in message 
> news:%23FF8jceCJHA.4576@TK2MSFTNGP05.phx.gbl...
>
> [please don't top-post]
>
>>>> I have an .htm file that shows in an iframe which is part of a master's 
>>>> asp:Content.
>>>>
>>>> But I don't know how to extract from Session("StyleSheetIndex"); rather 
>>>> than set it. And all the rest!
>>>>
>>>> Can this be done in JavaScript?
>>>
>>> No. JavaScript is client-side - it can't interrogate Session variables 
>>> because Session is server-side...
>>
>> Isn't there a way around that.
>
> Not while you're using an HTML file. HTML files are not processed by 
> ASP.NET - they are simply streamed to the client...
>
>> Maybe do save something additional when I save the session variable that 
>> will be available on the client side.
>
> I don't know how else to explain this to you - JavaScript runs on the 
> client. This means it can't interact with the server. Once a piece of 
> JavaScript has been streamed down to the client browser, the server has no 
> further control over it...
I understand the difference but I figured since the serrver side develops 
the HTML it might be able to stuff some data someplace in the HTML. Like 
your sugested a cookie. Now I'm familiar with the cookies on disk. But I 
gather from your suggesstion below that I can create one on the server that 
somehow becomes available on the client. (right?) I'll look into that.


>
> You could, perhaps, look at saving the Session variable as a cookie and 
> then retrieving it with JavaScript:
> http://www.google.co.uk/search?sourceid=navclient&hl=en-GB&ie=UTF-8&rlz=1T4GZEZ_en-GBGB252GB252&q=JavaScript+cookie
>
>> What about the rest of the code. Is it possible to convert that to 
>> JavaScript?

I meant, can the following be done using javascript? Seems to me that since 
the file Backgroundwhite.css is on the server the answer is no it can not be 
done in javascript - but I have little insight in this process and wanted to 
check before I gave up trying.



Dim objCSS As HtmlLink = New HtmlLink()

objCSS.Attributes.Add("href", "App_Themes/Backgroundwhite.css")

objCSS.Attributes.Add("rel", "stylesheet")

objCSS.Attributes.Add("type", "text/css")

HeadMaster.Controls.Add(objCSS)

Thanks a lot

>
> Server-side code is server-side code and client-side code is client-side 
> code... You cannot convert from one to the other, as they both run 
> completely separately one from the other...
>
>
> -- 
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
date: Fri, 29 Aug 2008 19:58:27 -0400   author:   _Who

Re: Convert vb to javascript?   
"bruce barker"  wrote in message 
news:873F19C7-33F5-4909-873B-D1BE91083729@microsoft.com...
> your javascript coudl make an ajax call to get the session value, then add 
> a
> css rule, but why bother. why don't you convert the html page to aspx, or 
> map
> .htm to asp.net so you can set the theme.
>
> -- bruce (sqlwork.com)
>
>
 The following is what I'm dealing with (where MissionScheduleID is an 
iframe).

I prefer that Mission.htm remain an html file but I suppose I could convert 
it to an aspx each time it is edited (often).

I looked into reading the mission.htm file and using document.writeln to 
insert the text instead of using an iframe but if I understand javascript 
does not do file input like that.

I would appreciate a few more words about your suggestions.

thanks



Protected WithEvents frame1 As System.Web.UI.HtmlControls.HtmlGenericControl

Protected Sub RadioButtonMission_CheckedChanged(ByVal sender As Object, 
ByVal e As System.EventArgs) Handles RadioButtonMission.CheckedChanged

frame1 = 
Me.Master.FindControl("Table1").FindControl("TableRow9").FindControl("TableCellR9C0").FindControl("MainMasterDataLeftID").FindControl("MissionScheduleID")

With frame1

.Attributes("src") = "Mission.htm"

.Attributes("width") = "100%"

.Attributes("height") = "100%"

End With

End Sub
date: Fri, 29 Aug 2008 20:14:31 -0400   author:   _Who

Re: Convert vb to javascript?   
"_Who"  wrote in message 
news:O96TiMjCJHA.2292@TK2MSFTNGP02.phx.gbl...

>> I don't know how else to explain this to you - JavaScript runs on the 
>> client. This means it can't interact with the server. Once a piece of 
>> JavaScript has been streamed down to the client browser, the server has 
>> no further control over it...
>
> I understand the difference but I figured since the serrver side develops 
> the HTML it might be able to stuff some data someplace in the HTML.

This applies only to files which ASP.NET processes... Ordinarily, ASP.NET 
doesn't process HTML files. Therefore, for HTML files, ASP.NET doesn't 
"develop the HTML" - it doesn't do anything to them at all...

> your sugested a cookie. Now I'm familiar with the cookies on disk. But I 
> gather from your suggesstion below that I can create one on the server 
> that somehow becomes available on the client. (right?) I'll look into 
> that.

No. ASP.NET can cause cookies to be created, but they are still created on 
the client. Cookies can't be created on the server...

>> What about the rest of the code. Is it possible to convert that to 
>> JavaScript?
>
> I meant, can the following be done using JavaScript?

No it can't.

> Seems to me that since the file Backgroundwhite.css is on the server the 
> answer is no it can not be done in JavaScript

Correct.


-- 
Mark Rae
ASP.NET MVP
http://www.markrae.net
date: Sat, 30 Aug 2008 01:18:33 +0100   author:   Mark Rae [MVP]

Re: Convert vb to javascript?   
"Mark Rae [MVP]"  wrote in message 
news:eM4XzXjCJHA.3268@TK2MSFTNGP03.phx.gbl...
> "_Who"  wrote in message 
> news:O96TiMjCJHA.2292@TK2MSFTNGP02.phx.gbl...
>
>>> I don't know how else to explain this to you - JavaScript runs on the 
>>> client. This means it can't interact with the server. Once a piece of 
>>> JavaScript has been streamed down to the client browser, the server has 
>>> no further control over it...
>>
>> I understand the difference but I figured since the serrver side develops 
>> the HTML it might be able to stuff some data someplace in the HTML.
>
> This applies only to files which ASP.NET processes... Ordinarily, ASP.NET 
> doesn't process HTML files. Therefore, for HTML files, ASP.NET doesn't 
> "develop the HTML" - it doesn't do anything to them at all...
>
>> your sugested a cookie. Now I'm familiar with the cookies on disk. But I 
>> gather from your suggesstion below that I can create one on the server 
>> that somehow becomes available on the client. (right?) I'll look into 
>> that.
>
> No. ASP.NET can cause cookies to be created, but they are still created on 
> the client. Cookies can't be created on the server...
>
>>> What about the rest of the code. Is it possible to convert that to 
>>> JavaScript?
>>
>> I meant, can the following be done using JavaScript?
>
> No it can't.
>
>> Seems to me that since the file Backgroundwhite.css is on the server the 
>> answer is no it can not be done in JavaScript
>
> Correct.
>
>
> -- 
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net

Guess that completly covers it. Thanks a lot.
>
date: Fri, 29 Aug 2008 21:20:46 -0400   author:   _Who

Re: Convert vb to javascript?   
I think I have it fixed.

In case anyone else has the same problem.

I read the .html file into a string, change the name of the .css file in 
that string, and write then a new .html file.

I still have a few ancilary things to fix but I have changed the stylesheet 
successfully.

All at the server.

Thanks for the help
date: Sat, 30 Aug 2008 11:42:06 -0400   author:   _Who

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us