java script postback problem in asp.net page

Last post 05-18-2008 11:07 AM by NC01. 5 replies.

Sort Posts:

  • java script postback problem in asp.net page

    05-17-2008, 1:40 AM

    hello,

    this is my javascript for popup window

    <script language="JavaScript">

     

    var w = window.open("http://localhost:5050/remotemeter/watermeter.aspx",'Srihari','toolbar=no,width=220,height=210');

     

    w.window.focus();

    </script>

    i have two buttons in asp.net page(update and live)

    when i click on live button the javascript is executed the page was open,but problem is when i click on update again javascript running the again page was open.

    in page load i put this code for update button

    protected void Page_Load(object sender, EventArgs e)

    {

     

     

     

    btnup.Attributes.Add("onclick","JavaScript:document.forms[0].reset(); return false;");

     

    }

    the update button code like below

    protected void btnup_Click(object sender, EventArgs e)

    {

     

    int recptr;
    SqlConnection con = new SqlConnection("server=localhost;initial catalog=online_application1;user id=sa;pwd=");

    con.Open();

    string st = "select * from packet";

    DataSet ds = new DataSet();

    DataRow dr;

    DataTable dt;

    SqlDataAdapter da = new SqlDataAdapter(st, con);

    da.Fill(ds, "packet");

    dt = ds.Tables[0];

    recptr = dt.Rows.Count - 1;

    dr = dt.Rows[recptr];

    lblrate.Text = dr[0].ToString();

    lblttl.Text = dr[1].ToString();

    lbltime1.Text = dr[2].ToString();

    lbldate1.Text = dr[3].ToString();

    con.Close();

    }

    when i click on update every time data will change .

    but using this code

    btnup.Attributes.Add("onclick","JavaScript:document.forms[0].reset(); return false;");

    only once the page will post back.

    my requirement is when iclick on update every time data is updated and when iclick on live the path will be open.

    plz help me

  • Re: java script postback problem in asp.net page

    05-17-2008, 4:32 AM

    when you want the update button "btnup" to always post back, i think you dont need to add the javascript block to the click event.

    it will automatically submit when a user click it.

     

    if you feel the script block is need, try like this 

    btnup.Attributes.Add("onclick","JavaScript:document.forms[0].reset(); return true;");

     

     

     

    -------------------------------------------------------------------
    Don't forget to click "Mark as Answer" on the post that helped you.

     

     

  • Re: java script postback problem in asp.net page

    05-17-2008, 4:44 AM

    btnup.Attributes.Add("onclick","JavaScript:document.forms[0].reset(); return true;");

    by using above stmt every time javascript calling

    when i click update button(btnup) every time the javascript is calling.

    i need only once to call javascript at pageloading.

    any postback method for javascript,plz send me sample code...

     

  • Re: java script postback problem in asp.net page

    05-17-2008, 4:56 AM

    try like this

     if( !IsPostBack)
    {
        btnup.Attributes.Add("onclick","JavaScript:document.forms[0].reset(); return true;");
    }

     

     

     

    ------------------------------------------------------------------------------------------------
    Don't forget to click "Mark as Answer" on the post that helped you.

  • Re: java script postback problem in asp.net page

    05-17-2008, 5:13 AM

    hi vineesh,

    i want postback for javascript...

    <script language="JavaScript">

    //here i want to place postbackIdea

    var w = window.open("http://localhost:5050/remotemeter/watermeter.aspx",'Srihari','toolbar=no,width=220,height=210');

     

    w.window.focus();

    </script>

  • Re: java script postback problem in asp.net page

    05-18-2008, 11:07 AM
    Answer
    • All-Star
      75,773 point All-Star
    • NC01
    • Member since 08-26-2005, 3:33 PM
    • Posts 14,128
    • TrustedFriends-MVPs

    Place
         <%= GetPostBackEventReference(this, string.Empty) %>;
    AFTER the window.open call.

    NC...

Page 1 of 1 (6 items)