Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Updating the html inside a panel

Reply
Thread Tools

Updating the html inside a panel

 
 
=?Utf-8?B?Rmx5Z3V5?=
Guest
Posts: n/a
 
      01-12-2007
How can I update the html inside of a panel?

How can I make this code work

<%@ Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

protected void Button1_Click(object sender, EventArgs e)
{
Panel1.innerHTML = "<html>Hello World!!!<html>"; //This will not
work.
}
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<aspanel ID="Panel1" runat="server" Height="144px" Style="z-index:
100; left: 64px;
position: absolute; top: 48px" Width="256px">
Say Hello</aspanel>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
Style="z-index: 102;
left: 104px; position: absolute; top: 200px" Text="Button"
Width="176px" />

</div>
</form>
</body>
</html>
 
Reply With Quote
 
 
 
 
Laurent Bugnion [MVP]
Guest
Posts: n/a
 
      01-12-2007
Hi,

Flyguy wrote:
> How can I update the html inside of a panel?
>
> How can I make this code work
>
> <%@ Page Language="C#" %>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <script runat="server">
>
> protected void Button1_Click(object sender, EventArgs e)
> {
> Panel1.innerHTML = "<html>Hello World!!!<html>"; //This will not
> work.
> }
> </script>


A Panel is rendered on the client by a DIV. You can see that by viewing
the HTML source sent to the client, always a good idea when something is
not working properly.

Since the Panel is a DIV, you may not use the "html" tags again, as they
are already present in the document.

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering: http://www.galasoft-LB.ch
PhotoAlbum: http://www.galasoft-LB.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
 
Reply With Quote
 
 
 
 
Aidy
Guest
Posts: n/a
 
      01-12-2007
You could use a Literal instead of a panel and set the Text property of the
literal;

MyLiteral.Text = "<p>Hello world</p>";

"Flyguy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> How can I update the html inside of a panel?
>
> How can I make this code work
>
> <%@ Page Language="C#" %>
>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
> "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
>
> <script runat="server">
>
> protected void Button1_Click(object sender, EventArgs e)
> {
> Panel1.innerHTML = "<html>Hello World!!!<html>"; //This will not
> work.
> }
> </script>
>
> <html xmlns="http://www.w3.org/1999/xhtml" >
> <head runat="server">
> <title>Untitled Page</title>
> </head>
> <body>
> <form id="form1" runat="server">
> <div>
> <aspanel ID="Panel1" runat="server" Height="144px"
> Style="z-index:
> 100; left: 64px;
> position: absolute; top: 48px" Width="256px">
> Say Hello</aspanel>
> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click"
> Style="z-index: 102;
> left: 104px; position: absolute; top: 200px" Text="Button"
> Width="176px" />
>
> </div>
> </form>
> </body>
> </html>



 
Reply With Quote
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      01-12-2007
Hi flyguy,

I can see your intension is to mark the "Hello World!!!" as html, therefore
you enclosed it in tag "<html></html>".

First, innerHTML is not a server-side property, it's a client-side property
(http://msdn2.microsoft.com/en-us/library/ms533897.aspx). You can use any
html source to set to this property, for example: <h1>Hello World!!!</h1>.
However, "<html></html>" is also a valid html tag which normally used in
the most outside of the html source.

To set the html inside the Panel at server-side, you can create a literal
control with the html source and add the control to the Panel:

LiteralControl lc = new LiteralControl("<h1>Hello World!!!</h1>");
panel1.Controls.Add(lc);


To set the html inside the Panel at client-side, you can use:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs"
Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript" language="javascript">
function test()
{
var panel2 = document.getElementById('panel2');
panel2.innerHTML = "<h1>Hello JavaScript!!!</h1>";
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<aspanel ID="panel1" runat="server"></aspanel>
<aspanel ID="panel2" runat="server"></aspanel>
<input type="button" onclick="test()" value="test" />
</div>
</form>
</body>
</html>


Hope this helps.

Sincerely,
Walter Wang ((E-Mail Removed), remove 'online.')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
Walter Wang [MSFT]
Guest
Posts: n/a
 
      01-12-2007
Hi Flyguy,

I'm not sure about your question. Would you please depict more? Thanks.

Regards,
Walter Wang ((E-Mail Removed), remove 'online.')
Microsoft Online Community Support

==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Updating a file inside a .war available inside .ear niceguyii Software 0 11-09-2011 01:37 PM
Updating JTable Atomically - block data changes while updating. news.rcn.com Java 2 12-10-2007 11:49 AM
updating an update panel from another updatepanel (AJAX) ma ASP .Net 3 09-29-2007 10:04 PM
Delete a panel inside a panel (2) HS1 Java 4 12-08-2004 02:48 AM
Delete a panel inside a panel HS1 Java 3 12-07-2004 10:50 PM



Advertisments