473,326 Members | 2,127 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Updating the html inside a panel

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>
<asp:Panel ID="Panel1" runat="server" Height="144px" Style="z-index:
100; left: 64px;
position: absolute; top: 48px" Width="256px">
Say Hello</asp:Panel>
<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>
Jan 12 '07 #1
4 15466
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
Jan 12 '07 #2
You could use a Literal instead of a panel and set the Text property of the
literal;

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

"Flyguy" <fl****@nospam.nospamwrote in message
news:14**********************************@microsof t.com...
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>
<asp:Panel ID="Panel1" runat="server" Height="144px"
Style="z-index:
100; left: 64px;
position: absolute; top: 48px" Width="256px">
Say Hello</asp:Panel>
<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>

Jan 12 '07 #3
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>
<asp:Panel ID="panel1" runat="server"></asp:Panel>
<asp:Panel ID="panel2" runat="server"></asp:Panel>
<input type="button" onclick="test()" value="test" />
</div>
</form>
</body>
</html>
Hope this helps.

Sincerely,
Walter Wang (wa****@online.microsoft.com, 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.

Jan 12 '07 #4
Hi Flyguy,

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

Regards,
Walter Wang (wa****@online.microsoft.com, 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.

Jan 12 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jay | last post by:
Hi all, May i know if there is any way by which we can render a given HTML inside .NET Windows Forms? We had the Web Browser controls in Visual Studio 6. Is there a follow-up of that in...
0
by: shustes | last post by:
Hi, I'm trying to essentially replicate a process that I had working well in classic ASP. I dump records within an HTML table to the web page. Within each record are textboxes and/or radio...
2
by: Amrit | last post by:
Hi Can anyone help me? I would really appreciate I am trying to scroll Groupboxes inside the panel when i hold panel's scroll bar and drag up and down. Such as Internet explorer where you can hold...
1
by: google | last post by:
Hi, Is there a way I can use html inside input box? I am making a autocomplete box and need to group tags visual (by appling similar color)... Abdul
1
chunk1978
by: chunk1978 | last post by:
hi there... i have a rather complex HTML form (involving hundreds of lines of Javascript, etc.) and i'd like to know if it's possible to embed HTML inside a Flash frame (or the like)... thanks
3
by: ma | last post by:
Hello, I have two update Panel in my page. I want to update one of these update panels from another one. How can I do this? How can I force the whole page to be updated from a button inside an...
1
by: BillGatesFan | last post by:
This is probably my second time using a GridView control and I cannot not figure out how to display HTML inside a datacolumn. Can somehow help me? I would be very surprised if it cannot be done. ...
1
by: rahullko05 | last post by:
Can anybody help me? to write one line code to render html inside a div element. Thanks.
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.