lamy
Regular
as an alternative for popup i made a script to make a DIV visible/hidden and place whatever page i needed to popup in its InnerHTML, the scripts works and now i wanted to make it a control so i dont have to paste/embed the code whenever i need to
heres what i have, on the HTML part, i placed the DIV and script that i needed
in my web form i have 2 buttons, one to hide it and the other to show the frame
in my code behind i added the onClick attributes to my buttons
so everything is working, except that i wanted to make that DIV move along as i scroll the page, to do that i needed to add some script
and that requires an additional attribute to my body
question 1: now, how do i set an attribute for my body in my usercontrol?
question 2: is it possible to make my DIV ID (MyDiv) as property, how?
question 3: and how do i set the properties of that DIV (say background, etc.)
i made a test web usercontrol and was able to get/set its properties
one way i could think of (havent tried though) is to render (Response.Write) an HTML with the values of each properties but dunno if itll do what i needed
was thinking of using it as popup and using it for my date picker aswell, anyone?
heres what i have, on the HTML part, i placed the DIV and script that i needed
Code:
<script language="javascript">
function Show(url)
{
var frm = document.getElementById("MyDiv");
frm.style.visibility = "visible";
frm.innerHTML = "<iframe src='" + url + "' ID='MyIFrame'></iframe>"
}
function Hide()
{
var frm = document.getElementById("MyDiv");
frm.style.visibility = "hidden";
}
</script>
<DIV id="MyDiv" style="position:absolute; visibility:hidden">
</DIV>
in my web form i have 2 buttons, one to hide it and the other to show the frame
Code:
<ASP:Button ID="btnHide" runat="Server" Text="Hide" />
<ASP:Button ID="btnShow" runat="Server" Text="Show" />
in my code behind i added the onClick attributes to my buttons
Visual Basic:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
btnHide.Attributes.Add("onClick", "Hide()")
btnShow.Attributes.Add("onClick", "Show('something.aspx')")
End Sub
so everything is working, except that i wanted to make that DIV move along as i scroll the page, to do that i needed to add some script
Code:
function Move(source)
{
var frm = document.getElementById("MyDiv");
var offset = 0;
// nothing to move
if (frm.style.visibility == "hidden")
return;
// IE compatible
if (document.all)
offset = source.scrollTop;
else
offset = document.body.scrollTop;
frm.style.top = frm.style.height + offset;
}
and that requires an additional attribute to my body
Code:
<body onMouseMove="Move(this)">
question 1: now, how do i set an attribute for my body in my usercontrol?
question 2: is it possible to make my DIV ID (MyDiv) as property, how?
question 3: and how do i set the properties of that DIV (say background, etc.)
i made a test web usercontrol and was able to get/set its properties
Visual Basic:
Private Something as String = String.Empty
<Personalizable()> _
Public Property MySomething() As String
Get
Return Something
End Get
Set(ByVal value As String)
Something = value
End Set
End Property
one way i could think of (havent tried though) is to render (Response.Write) an HTML with the values of each properties but dunno if itll do what i needed
was thinking of using it as popup and using it for my date picker aswell, anyone?