Framesets - server side control?

S

Sue

Is there such an animal as a frameset/frames server-side
webcontrol or htmlcontrol? I have a frameset with two
frames - one contains an aspx page with asp buttons that
has to do some updating, then change the aspx in the
second frame to another aspx. I've been trying various
ideas without success. Is there no way to do this on the
server side? Perplexed and wanting to drop kick this darn
app into orbit elsewhere.... tia, Sue
 
S

Steve C. Orr [MVP, MCSD]

S

Sue

I experimented with user controls (and like them), but
there were two problems for which I couldn't find a
solution: (1) loading all the user controls into one web
page (which seems to be what is preferred?) slowed the
page load to a crawl; (2) how to reference other user
controls controls? Any suggestions on where to find these
answers? tia, Sue
 
S

Steve C. Orr [MVP, MCSD]

You must have a whole lot of controls on your page.
You can optimize with some tips like these:
* HTML controls have a smaller memory footprint than web controls and
therefore may be more suitable for simple situations.
* static text can often be included in the HTML instead of using label
controls.
* Only use Autopostback when needed
* Turn on SmartNavigation

You can reference other control's controls by declaring them as public
instead of the default protected. Then you could use code like this:
Page.MyControl.MyTextBox

Or you can expose your control's controls through public function or
properties.
 
D

Dave Davidson

I'm not sure if this will work, but you could try the
HTMLGenericControl. Add an id="fraSet" and a
runat="server" to your frameset tag then a "Protected
WithEvents fraSet as HTMLGenericControl to your code-
behind. Then you should be able to modify what appears
inside the frameset with the InnerHTML property. The same
should work with frames.

BTW, we use the heck outa frames in our ASP.NET apps and
love them (but we don't have any server-side code to
modify the frameset's contents, just the pages displayed
in the frames).
 
S

Steven Cheng[MSFT]

Hi Sue,


Thank you for using Microsoft Newsgroup Services. Based on your desciption,
you are looking for some ASP.NET servercontrol or htmlcontrols which can
display as the frameset or frames in html page. As for this, I agree with
Steve, in ASP.NET there isn't such serverside controls which can directly
display as the frameset for frame. If you do want to implement frames and
frameset in ASP.NET webpage and control their attributes, I think you may
try using the client side script(such as javascript) together with the
serverside code.

As for the UserControl's problem you mentioned in the later reply. Yes,
since the UserControl is somewhat unlike the servercontrols and
htmlcontrols. It provides much more flexible featrures. When using
UserControls in an ASP.NET page, all the UserControls will be compiled the
first time the page is requested and stored in server memory to reduce the
response time for subsequent requests. So the it'll be somewhat slow the
first time page is requested. Also, since the UserControl is like a subpage
which is loaded into its container page at runtime, if you have many
UserControls in a page, the speed will be reduced. However, since the
ASP.NET has the cool feature "cache" which can save certain part of the
page(also for UserControls) so that the page can be render out much more
quickly. Also, besides adding a UserControl by delcaration, you can also
import a UserControl into a page programmatically and set their properties.
For more detailed in fomation on the ASP.NET UserControl, you can view the
following weblink in MSDN:
#This is a serial tutorial on Web Forms User Controls
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconwebformsusercontro
ls.asp?frame=true

#About Caching Multiple Versions of User Control Output
http://msdn.microsoft.com/library/en-us/cpguide/html/cpconcachingmultiplever
sionsofusercontroloutput.asp?frame=true

Please check out the preceding suggestions to see whether they are helpful.
If you have any question on it, please feel free to let me know.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
A

Anthony P. Mancini

If you have a webform on the buttons aspx page you can use a
"target=" attribute in your form tag. Not sure if you would set
the action attribute to the name of the aspx file you want to load
into the target frame or use a response.redirect to the intended
aspx file in your code behind the form. This doesn't work if the
form has some processing that posts back to itself. Also, .NET
only supports one frame on each page.

Anthony
 
G

Guest

I'm not sure if this will work, but you could try the
HTMLGenericControl. Add an id="fraSet" and a
runat="server" to your frameset tag then a "Protected
WithEvents fraSet as HTMLGenericControl to your code-
behind. Then you should be able to modify what appears
inside the frameset with the InnerHTML property. The same
should work with frames.

Dave, this looks interesting - thanks for the idea! I'll
give it a try this am. Sue
 
S

Sue

Also, .NET
only supports one frame on each page.

?? One? I've got a test frameset up with two frames and it
works. What sort of experience do you have for this? (I'd
rather know now than after I've put a lot of work into
this...) tia, Sue
 
S

Sue

I think you may
try using the client side script(such as javascript) together with the
serverside code.

I've got several client-side script blocks in this app,
but specifically with this problem, I tripped over an old
problem that I set aside over the xmas holiday hoping it'd
go away <hahahaha>. Specifically, I have/had set up
several html (image) buttons to control the display
property of different panels, tables, etc. among other
things. When I clicked on the button, the display property
changes as desired, but immediately reverted back to it's
original state. Tried many ideas to fix w/o luck (except
server-side buttons). Autopostback = false. The rendered
client-side code is correct. If I could get this to work,
the server-side issue here would be a moot point. thnx.
Sue
 
S

Sue

You must have a whole lot of controls on your page.

Yes - not my idea, believe me.
* HTML controls have a smaller memory footprint than web controls and
therefore may be more suitable for simple situations.

Use them as much as possible.
* static text can often be included in the HTML instead of using label
controls.

I do.
* Only use Autopostback when needed

I do.
* Turn on SmartNavigation

It's on.
You can reference other control's controls by declaring them as public
instead of the default protected. Then you could use

Uh...earth to Sue. Duh. Didn't think of this one. Thanks -
time to change some code.

Sue
 
A

Anthony P. Mancini

Sorry, meant to say one form tag on each page. The point
I was trying to make was having one form tag post to itself
(if it's needed) and having a second form tag post a page to
the second frame won't work.
 
S

Sue

Sorry, meant to say one form tag on each page. The point

Ah - thanks - that makes sense <g>. Thought I was losing
for a while there.... Sue
 
S

Steven Cheng[MSFT]

Hi Sue,

Thanks for your response. As for the problem you metioned that the html
element's display property you set in the clientside script will return
back to original value. I think this is because some of the button or other
control called a postback event, so the page is rendered again from the
server, all the html control's attribute is set back to the original value.
Since you want to remain the control's state when set at client side, I
think generally in web page, we can use some hidden area to store some of
the html element's clientside state so that when posted back to the server,
we can retrieve these values and set those html elements' property in terms
of the client side state. For example, such an aspx page which has an
<span> element, set it as runat=server so that we can manipulate it at
serverside.

----------aspx page-----------
<HTML>
<HEAD>
<title>BehindPage</title>
<meta content="Microsoft Visual Studio .NET 7.1" name="GENERATOR">
<meta content="C#" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
<script language="javascript">
function doDisplay(obj,state)
{
document.all.item(obj).style.display = state
document.all.item("hd" + obj).value = state
}
</script>
</HEAD>
<body>
<form id="Form1" method="post" runat="server">
<span id="spanMain" runat="server">
<TABLE id="Table1" align="center" cellSpacing="1" cellPadding="1"
width="300" border="1">
<TR>
<TD>
<asp:Label id="Label1" runat="server">Label</asp:Label></TD>
<TD>
<asp:TextBox id="TextBox1" runat="server"></asp:TextBox></TD>
<TD><FONT face="ËÎÌå">
<asp:Button id="Button1" runat="server"
Text="Button"></asp:Button></FONT></TD>
</TR>
<TR>
<TD><FONT face="ËÎÌå">
<asp:Label id="Label2" runat="server">Label</asp:Label></FONT></TD>
<TD><FONT face="ËÎÌå">
<asp:TextBox id="TextBox2" runat="server"></asp:TextBox></FONT></TD>
<TD>
<asp:Button id="Button2" runat="server"
Text="Button"></asp:Button></TD>
</TR>
<TR>
<TD>
<asp:Label id="Label3" runat="server">Label</asp:Label></TD>
<TD>
<asp:TextBox id="TextBox3" runat="server"></asp:TextBox></TD>
<TD>
<asp:Button id="Button4" runat="server"
Text="Button"></asp:Button></TD>
</TR>
</TABLE>
</span>
<table width="500" align="center">
<tr>
<td><input type="button" onclick="doDisplay('spanMain','none')"
value="HideSpan"> <input type="button"
onclick="doDisplay('spanMain','inline')" value="ShowSpan" id="Button3"
name="Button3" runat="server">
<asp:Button id="btnServer" runat="server" Text="ServerSide
Button"></asp:Button>
<input type="hidden" id="hdspanMain" value="inline" runat="server">
</td>
</tr>
</table>
</form>
</body>
</HTML>

in its code behind aspx.cs , we code the Page_Load event as this:
private void Page_Load(object sender, System.EventArgs e)
{
// Put user code to initialize the page here
if(hdspanMain.Value.Equals("none"))
{
spanMain.Attributes["style"] = "display:none";
}
else
{
spanMain.Attributes["style"] = "display:inline";
}

}

Thus, when the page is post back to server, we can check the hidden area's
value to determine how to set the html element's properties. Also, you can
extand the code according to your situation, the example just provided the
idea of maintaining the state between serverside postback.

Please try out the suggestion. If you have any question on it ,please feel
free to let me know.

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
 
S

Sue

Please try out the suggestion. If you have any question
on it ,please feel
free to let me know.

Steve, this example works fine. For other reasons, I have
abandoned working with client-side code for the moment.
Thanks for your help though!

Sue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,772
Messages
2,569,593
Members
45,111
Latest member
VetaMcRae
Top