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

Discussion in 'ASP .Net' started by KathyB, Jul 23, 2003.

  1. KathyB

    KathyB Guest

    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
     
    KathyB, Jul 23, 2003
    #1
    1. Advertising

  2. KathyB

    Ram Guest

    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.

    (KathyB) wrote in message news:<>...
    > 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
     
    Ram, Jul 23, 2003
    #2
    1. Advertising

  3. KathyB

    Kathy Burke Guest

    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+O2w8dDw7bDxpPDExPjtpPDEyPjtpPDE0P
    jtpPDE2PjtpPDI2PjtpPDI3Pjs+O2w8dDxwPHA8bDxUZXh0Oz47bDw7Pj47Pjs7Pjt0PHA8c
    DxsPFRleHQ7PjtsPDs+Pjs+Ozs+O3Q8cDxwPGw8VGV4dDs+O2w8Oz4+Oz47Oz47dDxwPHA8b
    DxUZXh0Oz47bDw7Pj47Pjs7Pjt0PHA8cDxsPFRleHQ7PjtsPFN0YXRpb24xOz4+Oz47Oz47d
    DxwPHA8bDxUZXh0Oz47bDxidXJrZWs7Pj47Pjs7Pjs+Pjs+Pjs+y1GvjoPDZcqlUFrke4R3X
    7FlTIw=" />

    <script language="javascript">
    <!--
    function __doPostBack(eventTarget, eventArgument) {
    var theform;
    if (window.navigator.appName.toLowerCase().indexOf("netscape") > -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!
     
    Kathy Burke, Jul 23, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Purvi T
    Replies:
    0
    Views:
    880
    Purvi T
    Oct 19, 2004
  2. KathyB
    Replies:
    1
    Views:
    7,642
    Mariya
    Sep 19, 2008
  3. Jeanne Louw
    Replies:
    2
    Views:
    6,363
    Alvin Bruney
    Jan 13, 2004
  4. Replies:
    3
    Views:
    1,009
  5. Replies:
    1
    Views:
    166
    James Britt
    Nov 24, 2005
Loading...

Share This Page