Click here to Skip to main content
15,892,298 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
I have to click twice the 'submit' button to effect its corresponding event. This btn control is not within any Update Panel. I debugged using a breakpoint at button4_clck event handler but it is not going to that breakpoint on the first click. However it goes only on the second click.

Hereunder is the code:

CSS
<asp:Button ID="Button4" runat="server"   CausesValidation="false"
  OnClick="Button4_Click"
style="z-index: 1; left: 185px; top: 2840px; position: absolute;  background-color:InactiveBorder;    height:30px; width:80px; font-size:large " ForeColor="Green" Text="Submit" />


C#
protected void Button4_Click(object sender, EventArgs e) // submit button
  {
Posted
Comments
Laiju k 12-Nov-14 7:12am    
post the code for Button4_Click
Remove the styles once and try.
S.Rajendran from Coimbatore 12-Nov-14 9:24am    
its not working.
S.Rajendran from Coimbatore 12-Nov-14 9:45am    
If validation is run for 1st time and then while proceeding with rectified 'submit' btn things are OK!
ZurdoDev 12-Nov-14 9:34am    
Have you put a breakpoint at the very first line in Button4_Click?
Also put a breakpoint in Page_Load.

seems like you have cache data. Clean your ASP.Net temp folder content. Clean solution. Try run again. It should work fine.

If not share the code.

Regards,
Maheswaran.s
 
Share this answer
 
Comments
S.Rajendran from Coimbatore 12-Nov-14 9:25am    
how to clean solution?
[no name] 12-Nov-14 9:38am    
Hey,

Go to Build in Menu Bar and use Clear Solution and use Rebuild.

Shrutik.
S.Rajendran from Coimbatore 12-Nov-14 9:48am    
There is nothing like clean solution under build
[no name] 12-Nov-14 10:05am    
hey,

is it possible for you to share that aspx file?

And in code in <asp:Button> try to use UseSubmitBehavior=true

Shrutik.
S.Rajendran from Coimbatore 12-Nov-14 11:07am    
UseSubmitBehavior is not helping..
Hey,

I think, I may have found a solution for you.

As I understood, Your Problem Was: "You want to update contents of UpdatePanel as many times you click Button4 (External Button - out of UpdatePanel)".

here is the reference that might help you:Introduction to the UpdatePanel Control:D

I tried your code my self:

I did put a Label in UpdatePanel and on Every Click it is writing DateTime.Now() to Label.

C#
<asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server">
            <ContentTemplate>
           
          
           <fieldset>
                <legend>Label Change on Button Click</legend>
                             
                <asp:Label ID="Label1" runat="server"  Text="In Heaven"/>               
                
           </fieldset>
          
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="Button1" />      
        </Triggers>
    </asp:UpdatePanel>


Steps:
1) Add Script Manager
2) Add Update Panel
(UpdateMode Conditional - bcoz we want to update on manual clicks)
and
3) Label1 is where we post changes on every click...

here in Triggers
we do not need to write EventName (By defaul system calls default Click method)
Here my button is "Button1" and Label in UpdatePanel is "Label1".


And to work with UpdateProgress ....
Please Read the reference about UpdateProgress particularly Programming UpdateProgress Controls in Client Script where and how to use UpdateProgress (bcoz in Update Progress you can only work with HTML elements - if you want to use that declared element in code behind - you have to work with javascripts - example: to abort post back).

I have tried my best to understand your question and
please refer to provided reference it will be more helpful.

Version of .Net Framework 4.0 and Asp.Net 2.

Thanks and Regards,
Shrutik Panchal.
 
Share this answer
 
v4
Comments
S.Rajendran from Coimbatore 12-Nov-14 22:46pm    
If I comment the UpdateProgress it works on first click. If not commented I have to
click twice.
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<contenttemplate>
<asp:Label ID="Label99" runat="server" Width="145px">


<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button4" />
</Triggers>

<script language="javascript" type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_initializeRequest(InitializeRequest);
prm.add_endRequest(EndRequest);
var postBackElement;
function InitializeRequest(sender, args) {

if (prm.get_isInAsyncPostBack())
args.set_cancel(true);
postBackElement = args.get_postBackElement();
if (postBackElement.id == 'Button4')
$get('UpdateProgress1').style.display = 'block';

}
function EndRequest(sender, args) {
if (postBackElement.id == 'Button4')
$get('UpdateProgress1').style.display = 'none';
}
</script>
<asp:UpdateProgress ID="UpdateProgress1" DynamicLayout=true AssociatedUpdatePanelID="UpdatePanel1" runat="server" >
<ProgressTemplate>
<table cellspacing="1" runat="server" id="table76" style=" margin-left:720px; margin-top:1360px; position:absolute;">
<tr>
<td>
<asp:Image ID="Image21" runat="server" DescriptionUrl="~/images/updateprogress.gif"
Height="60px" ImageUrl="~/images/updateprogress.gif" Width="20px" BackColor="White"/>
</td>
</tr>
</table>
</ProgressTemplate>
Laiju k 12-Nov-14 23:00pm    
have you debuged the javascript
S.Rajendran from Coimbatore 12-Nov-14 23:43pm    
No. If I comment the UpdateProgress it works on 1st click.
Laiju k 13-Nov-14 0:05am    
why are giving script in between source.
S.Rajendran from Coimbatore 13-Nov-14 0:54am    
Even it is kept under 'head' not working.

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