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.
精彩评论