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

Ask a Question related to ASP.NET General, Design and Development.

  1. #1

    Default 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
    KathyB Guest

  2. Similar Questions and Discussions

    1. Custom control on html page fails after VS project created
      I created a virtual directory and in the folder created an html file which includes an <object classid=...> tag that references a simple windows...
    2. run a script with a button on a php page
      Hi all, I'm new to PHP and I have I problem I can't solve right now. I have been searching the web but nothing yet... I have made a script which...
    3. Disguising a PHP script and parameters as a html page
      I'm not quite sure if the answer to my question lies in the Apache or PHP realm. If I have a php script running on Apache which outputs a JPEG...
    4. asp.net button.Attributes.Add (script not working)...why?
      Hi, I have an asp:button id="btnList" in an asp.net page. In the page load event (If NOT Postback), I have the following: ...
  3. #2

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

    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.

    [email]KathyBurke40@attbi.com[/email] (KathyB) wrote in message news:<75e8d381.0307221648.1e84a0a4@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
    Ram Guest

  4. #3

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

    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 [url]http://www.developersdex.com[/url] ***
    Don't just participate in USENET...get rewarded for it!
    Kathy Burke Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139