PC Review


Reply
Thread Tools Rate Thread

Convert vb to javascript?

 
 
_Who
Guest
Posts: n/a
 
      29th Aug 2008

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)


 
Reply With Quote
 
 
 
 
_Who
Guest
Posts: n/a
 
      29th Aug 2008
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]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "_Who" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>
>> 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



 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      29th Aug 2008
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]" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > "_Who" <(E-Mail Removed)> wrote in message
> > news:%(E-Mail Removed)...
> >
> >> 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

>
>
>

 
Reply With Quote
 
_Who
Guest
Posts: n/a
 
      30th Aug 2008

"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:OAF8%(E-Mail Removed)...
> "_Who" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>
> [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?sourc...aScript+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



 
Reply With Quote
 
_Who
Guest
Posts: n/a
 
      30th Aug 2008

"bruce barker" <(E-Mail Removed)> wrote in message
news:873F19C7-33F5-4909-873B-(E-Mail Removed)...
> 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


 
Reply With Quote
 
_Who
Guest
Posts: n/a
 
      30th Aug 2008

"Mark Rae [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> "_Who" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>
>>> 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.
>



 
Reply With Quote
 
_Who
Guest
Posts: n/a
 
      30th Aug 2008
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





 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Convert JavaScript Document reference to C# Cal Who Microsoft ASP .NET 1 3rd Jun 2010 07:48 PM
Convert VB.Net 2008 Objects to JavaScript? 14All2C@live.co.uk Microsoft VB .NET 2 18th Mar 2008 05:29 AM
How to fire Javascript events from a .NET winforms user control back to Javascript in IE jonathan.beckett Microsoft Dot NET 0 13th Jul 2006 02:51 PM
Convert Javascript client validator to C# server code Assimalyst Microsoft C# .NET 0 24th Mar 2006 02:05 PM
Javascript:void(null); or Javascript:; -problem clicking certain js action items chribjor Windows XP Internet Explorer 1 21st Jan 2004 11:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:24 AM.