473,387 Members | 1,536 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,387 software developers and data experts.

problem about postback and javascript

Hi,

There is a label and a textbox.
There are two buttons: one HTML (buttonA), the other ASP.NET (ButtonB).
Clicking on buttonA starts a javascript function, starting on ButtonB
triggers nothing but of course generates a postback.

Now my problem.
When clicking on buttonA, the text of the textbox and of the label are
modified by javascript, as expected.
When after that clicking on ButtonB, the only thing that happens is a
postback, so the original text of the label is back, but not as expected,
the original text of the textbox: it's still "textboxtext modified by
javascript".
Why?

Thanks
Phil

<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" Width="250px" Text="text
of textbox"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text="text of
label"></asp:Label>
<input id="Button1" type="button" value="buttonA" onclick="client()"
/>
<asp:Button ID="Button2" runat="server" Text="ButtonB" />
</div>
</form>
</body>
<script type="text/javascript">
function client()
{
document.getElementById("TextBox1").value="textbox text modified by
javascript"
document.getElementById("Label1").innerText="label tekst modified by
javascript"
}
</script>
May 23 '07 #1
2 1832
because textbox values are posted back. it doesn't matter if the user or
javascript changes the value.

a label is not a browser form element (input,select or textarea), so any
changes are not posted back.

-- bruce (sqlwork.com)
Phil wrote:
Hi,

There is a label and a textbox.
There are two buttons: one HTML (buttonA), the other ASP.NET (ButtonB).
Clicking on buttonA starts a javascript function, starting on ButtonB
triggers nothing but of course generates a postback.

Now my problem.
When clicking on buttonA, the text of the textbox and of the label are
modified by javascript, as expected.
When after that clicking on ButtonB, the only thing that happens is a
postback, so the original text of the label is back, but not as expected,
the original text of the textbox: it's still "textboxtext modified by
javascript".
Why?

Thanks
Phil

<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" Width="250px" Text="text
of textbox"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text="text of
label"></asp:Label>
<input id="Button1" type="button" value="buttonA" onclick="client()"
/>
<asp:Button ID="Button2" runat="server" Text="ButtonB" />
</div>
</form>
</body>
<script type="text/javascript">
function client()
{
document.getElementById("TextBox1").value="textbox text modified by
javascript"
document.getElementById("Label1").innerText="label tekst modified by
javascript"
}
</script>

May 23 '07 #2
Thanks

"bruce barker" <no****@nospam.comschreef in bericht
news:%2****************@TK2MSFTNGP02.phx.gbl...
because textbox values are posted back. it doesn't matter if the user or
javascript changes the value.

a label is not a browser form element (input,select or textarea), so any
changes are not posted back.

-- bruce (sqlwork.com)
Phil wrote:
>Hi,

There is a label and a textbox.
There are two buttons: one HTML (buttonA), the other ASP.NET (ButtonB).
Clicking on buttonA starts a javascript function, starting on ButtonB
triggers nothing but of course generates a postback.

Now my problem.
When clicking on buttonA, the text of the textbox and of the label are
modified by javascript, as expected.
When after that clicking on ButtonB, the only thing that happens is a
postback, so the original text of the label is back, but not as expected,
the original text of the textbox: it's still "textboxtext modified by
javascript".
Why?

Thanks
Phil

<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server" Width="250px"
Text="text of textbox"></asp:TextBox>
<asp:Label ID="Label1" runat="server" Text="text of
label"></asp:Label>
<input id="Button1" type="button" value="buttonA"
onclick="client()" />
<asp:Button ID="Button2" runat="server" Text="ButtonB" />
</div>
</form>
</body>
<script type="text/javascript">
function client()
{
document.getElementById("TextBox1").value="textbo xtext modified by
javascript"
document.getElementById("Label1").innerText="labe ltekst modified by
javascript"
}
</script>

May 23 '07 #3

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

Similar topics

0
by: Thomas Due | last post by:
Hello, I am in the process of making my asp.net form to validate as xhtml 1.0 strict. So far I am doing well, but now I have a problem. The problem concerns specifically DropDownList and...
5
by: Psych971 | last post by:
Hi, I'm wondering how I can generate a postback using javascript on a page that does not have any controls with the auto-postback property set to true. I know I can just use the submit() function...
3
by: Nick Goloborodko | last post by:
Hi, I've been having a really weird problem with required field validator. Here's the detailed description of the problem: I have originally been developing my web application on Windows XP...
6
by: | last post by:
Hi all, I have a bunch of dropdownlists that are populated in client-side javascript. When i do a postback I get the following error:- Invalid postback or callback argument. Event...
7
by: Cenk | last post by:
Hi, After converting my projects to ASP.Net 2.0 I have seen a problem with Page_unload. Ä°n framework 1.1 page_unload event fires when you are leaving the page or has closed the browser window....
7
by: Tony Girgenti | last post by:
Hello. I'm trying to undetrstand ASP.NET 2.0 and javascript. When i have a button and i click on it and i see the web broswer progress bar at the bottom do something, does that mean that there...
4
by: Harry | last post by:
Hi, This aspx page (let's call it thispage.aspx) fetches data from a sqldatasource, then performs several things (in code-behind) and, to simplify, passes data from code-behind via a hiddenfield...
9
by: =?Utf-8?B?TWFyYyBXb29sZnNvbg==?= | last post by:
I have what seems to be a relatively simple problem when attempting to simulate a postback in ASP.NET from JavaScript. My scenario is (and please don't ask me why) that I have an HTML <a>nchor...
4
by: Peter | last post by:
ASP.NET I have an application which use ASP.NET Autocomplete extender which works great. But I have a question how to update all the fields on the screen using Ajax. Users starts typing in a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.