Click here to Skip to main content
15,903,175 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my application when i click on button a popup window has to appear for single click but on second click the popup is coming.

here is the code

VB
<asp:Button ID="btnedit"
                      CssClass="editbtn" BorderWidth="0" Width="46px" Height="20px" runat="server"
                      onclick="btnedit_Click"  />

button code:

btnedit.Attributes.Add("onclick", "openemppostingjospopup('" + Convert.ToInt32(folderid) + "')");
Posted

Check where you have placed the code for "onclick".
If it is under if(!Page.IsPostBack), move it out of that if condition in Page_Load.
 
Share this answer
 
Comments
Ramu15 29-Mar-12 8:29am    
It is outside the page_Load only.
You are adding two eventhandlers to the same event 'onclick'.

One is -onclick="btnedit_Click" in the aspx
Other is - "onclick", "openemppostingjospopup('" + Convert.ToInt32(folderid) + "')"

So remove the onclick event from the aspx page. It will work.
 
Share this answer
 
Comments
Ramu15 30-Mar-12 4:31am    
if i take "btnedit_click" in aspx button is not firing pls send a example to remove it.
Ramu15 30-Mar-12 4:37am    
here is the code for edit button

protected void btnedit_Click(object sender, EventArgs e)
{

checkingmultiplevalues();
if (chckcount == 0)
{
lblERROR.Text = "please Select Atleast one folder";
lblerrr.Visible = true;
}
else
{


btnedit.Attributes.Add("onclick", "openemppostingjospopup('" + Convert.ToInt32(folderid) + "')");

}
}
bbirajdar 30-Mar-12 5:45am    
btnedit.Attributes.Add("onclick", "openemppostingjospopup('" + Convert.ToInt32(folderid) + "')");


This line of code should be in Page_Load event and NOT in the click event itself.
bbirajdar 30-Mar-12 5:46am    
Remove all your server side code and add the validation logic in javascript only
write your code :
C#
btnedit.Attributes.Add("onclick", "openemppostingjospopup('" + Convert.ToInt32(folderid) + "')"); 

inside page load.


it is written in event handler method of button click, thats why your pop up window is opening after post back .
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900