By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
439,978 Members | 1,362 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 439,978 IT Pros & Developers. It's quick & easy.

Resizing Frame

P: n/a
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("fstMainLayo ut");
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.GetTyp e(),
"jsfUtility", "<script type='text/javascript' language='javascript'
src='./Script_Data/jsfUtility.js'></script>");
this.ibtToggleNavFrame.Attributes["OnClick"] =
"jsfToggleNavFrame();";
}

Nov 23 '06 #1
Share this Question
Share on Google+
3 Replies


P: n/a
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" <he***********@gmail.comschreef in bericht
news:11**********************@l12g2000cwl.googlegr oups.com...
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("fstMainLayo ut");
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.GetTyp e(),
"jsfUtility", "<script type='text/javascript' language='javascript'
src='./Script_Data/jsfUtility.js'></script>");
this.ibtToggleNavFrame.Attributes["OnClick"] =
"jsfToggleNavFrame();";
}

Nov 23 '06 #2

P: n/a

wardemon wrote:
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();";

Nov 23 '06 #3

P: n/a
Hi Marss,
Thanks!! both worked!!

Regards,
Henry :)

marss wrote:
wardemon wrote:
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();";
Nov 23 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.