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

button created using attributes.add to run script in html...fires with each page postback

Hi, I have the following script in an aspx html:

<script language="javascript">
function pop_window()
{
var confirmWin = null;
confirmWin = window.open('Scanned.aspx', 'SerialNumbers',
'width=300,height=400,left=200,top=200,toolbar=no, resizable=no,menubar=no');
}
</script>

And in the code behind, this:

btnList.Attributes.Add("onclick", "pop_window();return false;")

The button works fine when clicked. My problem is that I have a text
box and every time the textchanged event is fired and does a page
postback, the button action fires as well.

Could someone please tell me how to fix this?

I've tried just doing an html button, but it wouldn't work correctly.

Thanks,

Kathy
Nov 17 '05 #1
2 4314
Ram
I tried with the code you provided and I don't find any problem.
Execute the page, in IE/NS go to view source and publish that source,
I can help you.

Ka**********@attbi.com (KathyB) wrote in message news:<75**************************@posting.google. com>...
Hi, I have the following script in an aspx html:

<script language="javascript">
function pop_window()
{
var confirmWin = null;
confirmWin = window.open('Scanned.aspx', 'SerialNumbers',
'width=300,height=400,left=200,top=200,toolbar=no, resizable=no,menubar=no');
}
</script>

And in the code behind, this:

btnList.Attributes.Add("onclick", "pop_window();return false;")

The button works fine when clicked. My problem is that I have a text
box and every time the textchanged event is fired and does a page
postback, the button action fires as well.

Could someone please tell me how to fix this?

I've tried just doing an html button, but it wouldn't work correctly.

Thanks,

Kathy

Nov 17 '05 #2
Thanks, Ram, here is the html source:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
<HEAD>
<title>Status</title>
<meta content="Microsoft Visual Studio.NET 7.0" name="GENERATOR">
<meta content="Visual Basic 7.0" name="CODE_LANGUAGE">
<meta content="JavaScript" name="vs_defaultClientScript">
<meta content="http://schemas.microsoft.com/intellisense/ie5"
name="vs_targetSchema">
</HEAD>
<body bgColor="#330099" MS_POSITIONING="GridLayout">
<form name="Form1" method="post" action="WIleft.aspx" id="Form1">
<input type="hidden" name="__EVENTTARGET" value="" />
<input type="hidden" name="__EVENTARGUMENT" value="" />
<input type="hidden" name="__VIEWSTATE"
value="dDwtMjA2Nzc0OTMwO3Q8O2w8aTwxPjs+O2w8dDw7bDx pPDExPjtpPDEyPjtpPDE0P
jtpPDE2PjtpPDI2PjtpPDI3Pjs+O2w8dDxwPHA8bDxUZXh0Oz4 7bDw7Pj47Pjs7Pjt0PHA8c
DxsPFRleHQ7PjtsPDs+Pjs+Ozs+O3Q8cDxwPGw8VGV4dDs+O2w 8Oz4+Oz47Oz47dDxwPHA8b
DxUZXh0Oz47bDw7Pj47Pjs7Pjt0PHA8cDxsPFRleHQ7PjtsPFN 0YXRpb24xOz4+Oz47Oz47d
DxwPHA8bDxUZXh0Oz47bDxidXJrZWs7Pj47Pjs7Pjs+Pjs+Pjs +y1GvjoPDZcqlUFrke4R3X
7FlTIw=" />

<script language="javascript">
<!--
function __doPostBack(eventTarget, eventArgument) {
var theform;
if (window.navigator.appName.toLowerCase().indexOf("n etscape") > -1) {
theform = document.forms["Form1"];
}
else {
theform = document.Form1;
}
theform.__EVENTTARGET.value = eventTarget.split("$").join(":");
theform.__EVENTARGUMENT.value = eventArgument;
theform.submit();
}
// -->
</script>

<span id="lblScanned" style="color:SpringGreen;font-family:Gill Sans
MT;font-size:Small;font-weight:bold;height:15px;width:130px;Z-INDEX:
110; LEFT: 73px; POSITION: absolute; TOP: 277px">Board in
Process</span><span id="lblMsg" style="color:Yellow;font-family:Gill
Sans
MT;font-size:Small;font-weight:bold;height:76px;width:223px;Z-INDEX:
128; LEFT: 28px; POSITION: absolute; TOP: 466px"></span><span
id="lblTotalWI" style="color:White;font-family:Gill Sans
MT;font-size:X-Small;font-weight:bold;height:15px;width:53px;Z-INDEX:
127; LEFT: 155px; POSITION: absolute; TOP: 369px"></span><span
id="Label5" style="color:Cyan;font-family:Gill Sans
MT;font-size:X-Small;font-weight:bold;height:15px;width:21px;Z-INDEX:
124; LEFT: 131px; POSITION: absolute; TOP: 369px">of</span><span
id="lblCurrentWI" style="color:White;font-family:Gill Sans
MT;font-size:X-Small;font-weight:bold;height:15px;width:40px;Z-INDEX:
122; LEFT: 107px; POSITION: absolute; TOP: 369px"></span><span
id="Label3" style="color:Cyan;font-family:Gill Sans
MT;font-size:Small;font-weight:bold;height:23px;width:217px;Z-INDEX:
126; LEFT: 32px; POSITION: absolute; TOP: 343px">WI in Process for this
Board</span><span id="lblWIPtotal" style="color:White;font-family:Gill
Sans
MT;font-size:X-Small;font-weight:bold;height:15px;width:53px;Z-INDEX:
125; LEFT: 153px; POSITION: absolute; TOP: 303px"></span><span
id="Label2" style="color:SpringGreen;font-family:Gill Sans
MT;font-size:X-Small;font-weight:bold;height:15px;width:21px;Z-INDEX:
123; LEFT: 131px; POSITION: absolute; TOP: 303px">of</span><span
id="lblWIP" style="color:White;font-family:Gill Sans
MT;font-size:X-Small;font-weight:bold;height:15px;width:40px;Z-INDEX:
121; LEFT: 107px; POSITION: absolute; TOP: 303px"></span><span
id="lbl_Qty" style="color:White;font-family:Gill Sans
MT;font-weight:bold;width:70px;Z-INDEX: 120; LEFT: 7px; POSITION:
absolute; TOP: 132px">Quantity:</span><span id="lblQty"
style="color:Yellow;font-family:Gill Sans MT;font-weight:bold;Z-INDEX:
118; LEFT: 114px; POSITION: absolute; TOP: 132px"></span><span
id="lblWO" style="color:Yellow;font-family:Gill Sans
MT;font-weight:bold;Z-INDEX: 119; LEFT: 114px; POSITION: absolute; TOP:
110px"></span><span id="Label1" style="color:White;font-family:Gill Sans
MT;font-weight:bold;width:70px;Z-INDEX: 114; LEFT: 7px; POSITION:
absolute; TOP: 88px">Assembly:</span><span id="lblAssy"
style="color:Yellow;font-family:Gill Sans
MT;font-weight:bold;width:183px;Z-INDEX: 117; LEFT: 114px; POSITION:
absolute; TOP: 88px"></span><span id="lbl_WO"
style="color:White;font-family:Gill Sans
MT;font-weight:bold;width:101px;Z-INDEX: 115; LEFT: 7px; POSITION:
absolute; TOP: 110px">Work Order:</span><span id="lblCust"
style="color:Yellow;font-family:Gill Sans MT;font-weight:bold;Z-INDEX:
116; LEFT: 114px; POSITION: absolute; TOP: 66px"></span><span
id="lbl_Cust" style="color:White;font-family:Gill Sans
MT;font-weight:bold;width:70px;Z-INDEX: 113; LEFT: 7px; POSITION:
absolute; TOP: 66px">Customer:</span><span id="lbl_User"
style="color:Yellow;font-family:Gill Sans
MT;font-weight:bold;width:70px;Z-INDEX: 112; LEFT: 7px; POSITION:
absolute; TOP: 34px">User:</span><span id="lblStation_label"
style="color:Yellow;font-family:Gill Sans
MT;font-weight:bold;width:70px;Z-INDEX: 111; LEFT: 7px; POSITION:
absolute; TOP: 15px">Station:</span><input name="txtFinish" type="text"
readonly="readonly" id="txtFinish"
style="background-color:Silver;font-size:XX-Small;width:65px;Z-INDEX:
104; LEFT: 142px; POSITION: absolute; TOP: 417px" /><span id="lblScan"
style="color:Yellow;font-family:Gill Sans
MT;font-size:Small;font-weight:bold;height:23px;width:169px;Z-INDEX:
108; LEFT: 63px; POSITION: absolute; TOP: 193px">Scan Serial
Number</span><input name="txtScan" type="text"
onchange="__doPostBack('txtScan','')" language="javascript" id="txtScan"
style="width:144px;Z-INDEX: 107; LEFT: 63px; POSITION: absolute; TOP:
221px" /><span id="lblFinish" style="color:Cyan;font-family:Gill Sans
MT;font-size:X-Small;font-weight:bold;height:15px;width:47px;Z-INDEX:
106; LEFT: 156px; POSITION: absolute; TOP: 397px">Finish</span><span
id="lblStart" style="color:Cyan;font-family:Gill Sans
MT;font-size:X-Small;font-weight:bold;height:15px;width:47px;Z-INDEX:
105; LEFT: 80px; POSITION: absolute; TOP: 397px">Start</span><input
name="txtStart" type="text" readonly="readonly" id="txtStart"
style="background-color:Silver;font-size:XX-Small;width:65px;Z-INDEX:
103; LEFT: 63px; POSITION: absolute; TOP: 417px" /><span id="lblStation"
style="color:White;font-family:Gill Sans MT;font-weight:bold;Z-INDEX:
101; LEFT: 114px; POSITION: absolute; TOP: 14px">Station1</span><span
id="lblUser" style="color:White;font-family:Gill Sans
MT;font-weight:bold;Z-INDEX: 102; LEFT: 114px; POSITION: absolute; TOP:
35px">burkek</span>
<HR style="Z-INDEX: 109; LEFT: 6px; POSITION: absolute; TOP: 168px;
HEIGHT: 5px" width="100%" color="#ff0000" SIZE="5">
</form>
</body>
</HTML>
Kathy

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 17 '05 #3

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

Similar topics

14
by: tshad | last post by:
I posted this on the asp.net group, also. I wasn't sure whether this was an asp.net problem or a javascript problem. I have a page that was originally created from a program I found on the net...
3
by: IntraRELY | last post by:
I need to attach the following 2 little scripts to an ASP.NET Button. I am having an issue with running both of the Attributes.Add. I can only get on to work at once. I have also tried to put them...
3
by: Charlie | last post by:
Hi: when the user selects the save button (asp control) to intiate a postback, I would like to pop up a javascript alert box to confirm if he really wants to save. If he selects no from alert...
4
by: Carlo Marchesoni | last post by:
I have a button that opens a new Window (some kind of search-window), which is fired using JavaScript (btnSearch.Attributes=".....";) Now I need to run some code behind code BEFORE this JavaScript...
5
by: Girish | last post by:
I have TWO submit buttons of type IMAGE on my asp form. This renders as <input type="image">. I need to be able to eble the ENTER button for both buttons. Yes, I know that for the input type...
4
by: Jeremy | last post by:
I have an ASPX page with a bunch of System.Web.UI.WebControls.Button controls on it. By default, clicking on any of these causes a Postback. I'd like to have it so that for a couple of these...
4
by: JJ | last post by:
Hi, I need to have a button cause an autopostback. How can I do this? I have textboxs on webform that supply values for a calc but not all will get filled at any particular time. So I need a...
9
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT...
11
by: bill | last post by:
I dynamically create buttons and associate them with an event using AddHandler. I want all the button events to fire at one time, when the page is posted, instead of when each button is clicked....
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...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...

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.