Convert vb to javascript?

  • Thread starter Thread starter _Who
  • Start date Start date
W

_Who

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)
 
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)
 
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 said:
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 said:
[please don't top-post]
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?sour...z=1T4GZEZ_en-GBGB252GB252&q=JavaScript+cookie

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
 
bruce barker said:
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
 
Mark Rae said:
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...


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...


No it can't.


Correct.

Guess that completly covers it. Thanks a lot.
 
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
 
Back
Top