开发者

how to get backgroung color value of html page into .aspx.cs page?

开发者 https://www.devze.com 2022-12-09 15:46 出处:网络
I have a html page with some code like <div style=\"background-color: rgb(191, 122, 111);\"> function Gettbgcolor(obj)

I have a html page with some code like

<div style="background-color: rgb(191, 122, 111);">



 function Gettbgcolor(obj)
  {
    var bgcolor = obj.style.backgroundColor;
    parent.GetLayoutbackgroundcolor(bgcolor);
  }

I used iframe into .aspx page and calling this html page into i frame.

And i have another page name home.aspx and i want call this value into .aspx.cs.

and i am using this code in home.aspx page

function GetLayoutbackgroundcolor(bgcolor) 

{

form1.hdColorSchemaBackground.value = bgcolor;
alert(form1.hdColorSchemaBackground.value);

}

hdColorSchemaBackgrou开发者_如何转开发nd is asp hiddenfield but its not get the value of bg color how can i do this


ASP.NET chooses its own id and name attributes for hidden inputs created with the <asp:HiddenField> tag. That's why your JavaScript won't set the field's value.

You can do something like this instead:

function GetLayoutbackgroundcolor(bgcolor)
{
    var formField = document.getElementById('<%= hdColorSchemaBackground.ClientID %>');

    formField.value = bgcolor;
}

That will insert the correct (client-side) id value for your javascript.

0

精彩评论

暂无评论...
验证码 换一张
取 消