Resizing Frame

  • Thread starter Thread starter wardemon
  • Start date Start date
W

wardemon

Hi All,
I would like to ask how can one resize a frame in a website w/o
postback?
My scenario is the following
I have a left frame, a top frame, and a "contents" frame.
I placed an imagebutton in the top frame that once clicked, it will
fire
a javascript code the will resize the left frame (collapse), then if
clicked again,
it will "expand" or restore the left frame's size back to its
original size.

My problem is that whenever you click the image button in the top
frame to
resize the left frame, the top frame posts back.

Is there anyway for the top frame not to postback?

Thanks,
Henry

Javascript
===========================================================
function jsfToggleNavFrame()
{
var frame = window.parent.document.getElementById("fstMainLayout");
var navFrameCol = frame.cols.substr(0, frame.cols.indexOf(','));
alert (navFrameCol);
if (navFrameCol != 216)
{
frame.cols="216,*";
}
else
{
frame.cols="*,100%";
}
}


Code Behind
===========================================================

protected void Page_Load(object sender, EventArgs e)
{
ClientScript.RegisterClientScriptBlock(this.GetType(),
"jsfUtility", "<script type='text/javascript' language='javascript'
src='./Script_Data/jsfUtility.js'></script>");
this.ibtToggleNavFrame.Attributes["OnClick"] =
"jsfToggleNavFrame();";
}
 
Wardemon,

If you have done that, than there most be somewhere a property postback on
click set.
In my idea are the only controls that have that build in are the button and
the link button.

Cor
 
wardemon said:
My problem is that whenever you click the image button in the top
frame to
resize the left frame, the top frame posts back.

Is there anyway for the top frame not to postback?
..
this.ibtToggleNavFrame.Attributes["OnClick"] =
"jsfToggleNavFrame();";
}

Hi,

That happen because ImageButton is rendered in HTML element <input
type="image" ...>
that submits form on click. You can prevent its default action in this
way:
change
this.ibtToggleNavFrame.Attributes["onclick"] = "jsfToggleNavFrame();";
to
this.ibtToggleNavFrame.Attributes["onclick"] =
"jsfToggleNavFrame();return false;";

There is the different way to solve this problem:
If only functionality you need from the button is calling javascript
function then
use Image instead of ImageButton.

protected Image imgToggleNavFrame;
.........
this.imgToggleNavFrame.Attributes["onclick"] = "jsfToggleNavFrame();";
 
Hi Marss,
Thanks!! both worked!!

Regards,
Henry :)
wardemon said:
My problem is that whenever you click the image button in the top
frame to
resize the left frame, the top frame posts back.

Is there anyway for the top frame not to postback?
.
this.ibtToggleNavFrame.Attributes["OnClick"] =
"jsfToggleNavFrame();";
}

Hi,

That happen because ImageButton is rendered in HTML element <input
type="image" ...>
that submits form on click. You can prevent its default action in this
way:
change
this.ibtToggleNavFrame.Attributes["onclick"] = "jsfToggleNavFrame();";
to
this.ibtToggleNavFrame.Attributes["onclick"] =
"jsfToggleNavFrame();return false;";

There is the different way to solve this problem:
If only functionality you need from the button is calling javascript
function then
use Image instead of ImageButton.

protected Image imgToggleNavFrame;
........
this.imgToggleNavFrame.Attributes["onclick"] = "jsfToggleNavFrame();";
 
Back
Top