javascript - ASP.Net How to programmatically add a background image for my site? -


i want add background image site programmatically code have came upon not work.

first use javascript print browsers dimensions:

$(document).ready(function () {     $("#clientscreenwidth").val($(window).width());     $("#clientscreenheight").val($(window).height()); }); 

after send these dimensions vb.net via hidden inputs , assign them values:

dim height string = httpcontext.current.request.params("clientscreenheight") dim width string = httpcontext.current.request.params("clientscreenwidth") 

however when tried input these arguments string , pass body's css there error:

dim backgroundimageurl string = "https://unsplash.it/" + height + "/" + width body.style.add("background-image: url(""" + backgroundimageurl + """);") 

overload resolution failed becuase no accessible 'add' accepts number of arguments.

edit:

posting fixed overload resolution error!

the syntax "classid.style.add("first part of css name", "second part")"

example: body.style.add("background-image", "url(""http://google.com/logo.png"")")

to edit body style in .net codebehind, add id , runat="server". becomes easier reference in .net.

<body id="body1" runat="server">  </body> 

code behind:

dim backgroundimageurl string = "https://unsplash.it/" + height + "/" + width  body1.attributes["style"] = "background-image: url(\"" + backgroundimageurl + "\");" 

Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -