473,594 Members | 2,651 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="javas cript">
function pop_window()
{
var confirmWin = null;
confirmWin = window.open('Sc anned.aspx', 'SerialNumbers' ,
'width=300,heig ht=400,left=200 ,top=200,toolba r=no,resizable= no,menubar=no') ;
}
</script>

And in the code behind, this:

btnList.Attribu tes.Add("onclic k", "pop_window();r eturn 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 4334
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**********@at tbi.com (KathyB) wrote in message news:<75******* *************** ****@posting.go ogle.com>...
Hi, I have the following script in an aspx html:

<script language="javas cript">
function pop_window()
{
var confirmWin = null;
confirmWin = window.open('Sc anned.aspx', 'SerialNumbers' ,
'width=300,heig ht=400,left=200 ,top=200,toolba r=no,resizable= no,menubar=no') ;
}
</script>

And in the code behind, this:

btnList.Attribu tes.Add("onclic k", "pop_window();r eturn 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="Micros oft Visual Studio.NET 7.0" name="GENERATOR ">
<meta content="Visual Basic 7.0" name="CODE_LANG UAGE">
<meta content="JavaSc ript" name="vs_defaul tClientScript">
<meta content="http://schemas.microso ft.com/intellisense/ie5"
name="vs_target Schema">
</HEAD>
<body bgColor="#33009 9" MS_POSITIONING= "GridLayout ">
<form name="Form1" method="post" action="WIleft. aspx" id="Form1">
<input type="hidden" name="__EVENTTA RGET" value="" />
<input type="hidden" name="__EVENTAR GUMENT" value="" />
<input type="hidden" name="__VIEWSTA TE"
value="dDwtMjA2 Nzc0OTMwO3Q8O2w 8aTwxPjs+O2w8dD w7bDxpPDExPjtpP DEyPjtpPDE0P
jtpPDE2PjtpPDI2 PjtpPDI3Pjs+O2w 8dDxwPHA8bDxUZX h0Oz47bDw7Pj47P js7Pjt0PHA8c
DxsPFRleHQ7Pjts PDs+Pjs+Ozs+O3Q 8cDxwPGw8VGV4dD s+O2w8Oz4+Oz47O z47dDxwPHA8b
DxUZXh0Oz47bDw7 Pj47Pjs7Pjt0PHA 8cDxsPFRleHQ7Pj tsPFN0YXRpb24xO z4+Oz47Oz47d
DxwPHA8bDxUZXh0 Oz47bDxidXJrZWs 7Pj47Pjs7Pjs+Pj s+Pjs+y1GvjoPDZ cqlUFrke4R3X
7FlTIw=" />

<script language="javas cript">
<!--
function __doPostBack(ev entTarget, eventArgument) {
var theform;
if (window.navigat or.appName.toLo werCase().index Of("netscape") > -1) {
theform = document.forms["Form1"];
}
else {
theform = document.Form1;
}
theform.__EVENT TARGET.value = eventTarget.spl it("$").join(": ");
theform.__EVENT ARGUMENT.value = eventArgument;
theform.submit( );
}
// -->
</script>

<span id="lblScanned " style="color:Sp ringGreen;font-family:Gill Sans
MT;font-size:Small;font-weight:bold;hei ght:15px;width: 130px;Z-INDEX:
110; LEFT: 73px; POSITION: absolute; TOP: 277px">Board in
Process</span><span id="lblMsg" style="color:Ye llow;font-family:Gill
Sans
MT;font-size:Small;font-weight:bold;hei ght:76px;width: 223px;Z-INDEX:
128; LEFT: 28px; POSITION: absolute; TOP: 466px"></span><span
id="lblTotalWI " style="color:Wh ite;font-family:Gill Sans
MT;font-size:X-Small;font-weight:bold;hei ght:15px;width: 53px;Z-INDEX:
127; LEFT: 155px; POSITION: absolute; TOP: 369px"></span><span
id="Label5" style="color:Cy an;font-family:Gill Sans
MT;font-size:X-Small;font-weight:bold;hei ght:15px;width: 21px;Z-INDEX:
124; LEFT: 131px; POSITION: absolute; TOP: 369px">of</span><span
id="lblCurrentW I" style="color:Wh ite;font-family:Gill Sans
MT;font-size:X-Small;font-weight:bold;hei ght:15px;width: 40px;Z-INDEX:
122; LEFT: 107px; POSITION: absolute; TOP: 369px"></span><span
id="Label3" style="color:Cy an;font-family:Gill Sans
MT;font-size:Small;font-weight:bold;hei ght:23px;width: 217px;Z-INDEX:
126; LEFT: 32px; POSITION: absolute; TOP: 343px">WI in Process for this
Board</span><span id="lblWIPtotal " style="color:Wh ite;font-family:Gill
Sans
MT;font-size:X-Small;font-weight:bold;hei ght:15px;width: 53px;Z-INDEX:
125; LEFT: 153px; POSITION: absolute; TOP: 303px"></span><span
id="Label2" style="color:Sp ringGreen;font-family:Gill Sans
MT;font-size:X-Small;font-weight:bold;hei ght:15px;width: 21px;Z-INDEX:
123; LEFT: 131px; POSITION: absolute; TOP: 303px">of</span><span
id="lblWIP" style="color:Wh ite;font-family:Gill Sans
MT;font-size:X-Small;font-weight:bold;hei ght:15px;width: 40px;Z-INDEX:
121; LEFT: 107px; POSITION: absolute; TOP: 303px"></span><span
id="lbl_Qty" style="color:Wh ite;font-family:Gill Sans
MT;font-weight:bold;wid th:70px;Z-INDEX: 120; LEFT: 7px; POSITION:
absolute; TOP: 132px">Quantity :</span><span id="lblQty"
style="color:Ye llow;font-family:Gill Sans MT;font-weight:bold;Z-INDEX:
118; LEFT: 114px; POSITION: absolute; TOP: 132px"></span><span
id="lblWO" style="color:Ye llow;font-family:Gill Sans
MT;font-weight:bold;Z-INDEX: 119; LEFT: 114px; POSITION: absolute; TOP:
110px"></span><span id="Label1" style="color:Wh ite;font-family:Gill Sans
MT;font-weight:bold;wid th:70px;Z-INDEX: 114; LEFT: 7px; POSITION:
absolute; TOP: 88px">Assembly: </span><span id="lblAssy"
style="color:Ye llow;font-family:Gill Sans
MT;font-weight:bold;wid th:183px;Z-INDEX: 117; LEFT: 114px; POSITION:
absolute; TOP: 88px"></span><span id="lbl_WO"
style="color:Wh ite;font-family:Gill Sans
MT;font-weight:bold;wid th:101px;Z-INDEX: 115; LEFT: 7px; POSITION:
absolute; TOP: 110px">Work Order:</span><span id="lblCust"
style="color:Ye llow;font-family:Gill Sans MT;font-weight:bold;Z-INDEX:
116; LEFT: 114px; POSITION: absolute; TOP: 66px"></span><span
id="lbl_Cust" style="color:Wh ite;font-family:Gill Sans
MT;font-weight:bold;wid th:70px;Z-INDEX: 113; LEFT: 7px; POSITION:
absolute; TOP: 66px">Customer: </span><span id="lbl_User"
style="color:Ye llow;font-family:Gill Sans
MT;font-weight:bold;wid th:70px;Z-INDEX: 112; LEFT: 7px; POSITION:
absolute; TOP: 34px">User:</span><span id="lblStation_ label"
style="color:Ye llow;font-family:Gill Sans
MT;font-weight:bold;wid th:70px;Z-INDEX: 111; LEFT: 7px; POSITION:
absolute; TOP: 15px">Station:</span><input name="txtFinish " type="text"
readonly="reado nly" id="txtFinish"
style="backgrou nd-color:Silver;fo nt-size:XX-Small;width:65p x;Z-INDEX:
104; LEFT: 142px; POSITION: absolute; TOP: 417px" /><span id="lblScan"
style="color:Ye llow;font-family:Gill Sans
MT;font-size:Small;font-weight:bold;hei ght:23px;width: 169px;Z-INDEX:
108; LEFT: 63px; POSITION: absolute; TOP: 193px">Scan Serial
Number</span><input name="txtScan" type="text"
onchange="__doP ostBack('txtSca n','')" language="javas cript" id="txtScan"
style="width:14 4px;Z-INDEX: 107; LEFT: 63px; POSITION: absolute; TOP:
221px" /><span id="lblFinish" style="color:Cy an;font-family:Gill Sans
MT;font-size:X-Small;font-weight:bold;hei ght:15px;width: 47px;Z-INDEX:
106; LEFT: 156px; POSITION: absolute; TOP: 397px">Finish</span><span
id="lblStart" style="color:Cy an;font-family:Gill Sans
MT;font-size:X-Small;font-weight:bold;hei ght:15px;width: 47px;Z-INDEX:
105; LEFT: 80px; POSITION: absolute; TOP: 397px">Start</span><input
name="txtStart" type="text" readonly="reado nly" id="txtStart"
style="backgrou nd-color:Silver;fo nt-size:XX-Small;width:65p x;Z-INDEX:
103; LEFT: 63px; POSITION: absolute; TOP: 417px" /><span id="lblStation "
style="color:Wh ite;font-family:Gill Sans MT;font-weight:bold;Z-INDEX:
101; LEFT: 114px; POSITION: absolute; TOP: 14px">Station1</span><span
id="lblUser" style="color:Wh ite;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
5446
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 that works well as an html page. It brings up a modal popup window that I have been trying to work out for days now and this was the closest I have been able to come. I added a little asp.net code and an asp.net button and cannot get it to
3
2259
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 both/either in the page_load, but cannot get it to work. TIA, Steve Wofford www.IntraRELY.com
3
2158
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 dialog, I would like to cancel the postback. How do you do this? Thanks, Charlie
4
5533
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 runs. I tried to define another Button with an EventHandler associated, and from this (after doing my code) fire 'btnSearch.click()'. But I can't make it work. I tried private void Button1_Click(object sender, System.EventArgs e RestartAll()...
5
1922
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 image, the submit happens automatically to the server. Heres my problem: I have two event handlers for both these buttons as stated below: BUTTON 1:
4
17090
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 buttons, no PostBack occurs - and rather some client-side script is executed (with no postback subsequently occuring). I have wired up the client-side script to the Buttons in question using Attributes.Add(blah blah blah) - now I just need to somehow...
4
10436
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 button that signals once user is done to do an autopostback. How can I do this? Thanks, JJ
9
2767
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 IS IMPOSSIBLE TO PROGRAMMATICALLY ADD A BUTTON TO A DYNAMICALLY CREATED PAGE. Or, to be more precise, why it is impossible to have an onClick sub respond to that button’s Click event. My main page has only one line:
11
4207
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. How I stop the buttons from posting back when they are clicked? Thanks
0
7941
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7874
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8000
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6652
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5738
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5404
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3854
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1476
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1205
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.