Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Prevent postback

Posted on 2006-04-05
5
Medium Priority
?
2,610 Views
Last Modified: 2012-06-27
I have a link button on the main page.If  I click the linkbutton, it will open up the pop-up window that has a gridview.
I would like to prevent the postback on the mainpage when I click the linkbutton. How can I do this?
Do I have to write a clientside Java script? How can I do this? can you show me some examples in C#?


protected void LinkButton1_PreRender(object sender, EventArgs e)
    {
        LinkButton viewtemp = LinkButton1;
        int mm = Convert.ToInt32(DropDownList1.SelectedValue);
        int yy = Convert.ToInt32(DropDownList2.SelectedValue);
        string unitabbr = DropDownList3.SelectedValue;
        viewtemp.OnClientClick = "javascript:popup_window=window.open('Previous_Debt_Temp.aspx?month=" + mm + " and year=" + yy + " and unit_abbr=" + unitabbr +
        "','popup_window','width=720,height=530,top=50,scrollbars=1,title=Hello');popup_window.focus()";
         
    }
0
Comment
Question by:jung1975
3 Comments
 
LVL 7

Expert Comment

by:whityum
ID: 16382470
you could use an HyperLink instead, a link button posts event args back to the page.
0
 
LVL 18

Accepted Solution

by:
Elvio Lujan earned 1000 total points
ID: 16383627
protected void LinkButton1_PreRender(object sender, EventArgs e)
    {
        LinkButton viewtemp = LinkButton1;
        int mm = Convert.ToInt32(DropDownList1.SelectedValue);
        int yy = Convert.ToInt32(DropDownList2.SelectedValue);
        string unitabbr = DropDownList3.SelectedValue;
        viewtemp.OnClientClick = "javascript:popup_window=window.open('Previous_Debt_Temp.aspx?month=" + mm + " and year=" + yy + " and unit_abbr=" + unitabbr +
        "','popup_window','width=720,height=530,top=50,scrollbars=1,title=Hello');popup_window.focus();return false;";
         
    }
0
 
LVL 1

Expert Comment

by:ghostReckon
ID: 16386988
Write everything in the mainpage's PageLoad event inside Postback function

private void Page_Load(object sender, System.EventArgs e)
{
                  
      if (! IsPostBack)
      {
               // your code...
         }

}

Cheers
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
In an ASP.NET application, I faced some technical problems. In this article, I list them out and show the solutions that I found.  I hope it will be useful. Problem: After closing a pop-up window, the parent page should be refreshed automaticall…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
Suggested Courses
Course of the Month20 days, 19 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question