[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 847
  • Last Modified:

Javascript popup need to open only on onload event of asp.net page

I called a popup window on onload event of a asp.net page.In the page I have a gridview including linkbutton coliumn. When I click on link button of gridview popup window again opens, while I want that it open only when I open page first time .
0
konfusion
Asked:
konfusion
  • 2
  • 2
1 Solution
 
Ashish PatelCommented:
Change you link button from ASP.net type to simple html button and place a onClick to it

OR

on the link button just write onClick=" return false;" at the end. Can you paste you code of link button if you dont understand what i mean to say?
0
 
konfusionAuthor Commented:
ya sure
<ItemTemplate>
                                <asp:LinkButton ID="lnkParticipantId" runat="server" CommandArgument='<%# Eval("participantid") %>'
                                    CommandName="SetLabel"><%# Eval("participantid")%></asp:LinkButton>
                            </ItemTemplate>

this commandname "setlabel" i m accessing in cs file as -
protected void PatientSearchResults_RowCommand(Object sender, GridViewCommandEventArgs e)
        {
            if (IsPostBack)
            {
                if (e.CommandName == "SetLabel")
                {
                    divQuestion.Visible = true;
                }
            }
            else
            {
                divQuestion.Visible = false;
            }
        }
}
0
 
Ashish PatelCommented:
Basically what is happening here is when  you click the asp:LinkButton it post's back the request and after processing the action of link button the page is reloaded. So, here may be you can remove the onLoad from the <body tag and in the code behind, when its IsPostBack == false at that time you execute the script of the page at the end. Something like this in the Page_Load should be there.

if (!IsPostBack)
     Page.ClientScript.RegisterStartupScript(Me.GetType(), "onload", "<script>ONLOADFUNCTION();</script>")

Note: Please change the ONLOADFUNCTION with the function which you are calling during onload.
0
 
konfusionAuthor Commented:
Ya it works...
Thanks!
0

Featured Post

Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now