code_junkie

Why does a button control need to be clicked twice?

Nov 10th, 2011
112
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.35 KB | None | 0 0
  1. <asp:panel ID="Panel2" DefaultButton="btnPrvCmt" runat=server>
  2. <asp:Panel id="pnldetTI" runat="server" cssclass="collapsePanel" >
  3. <asp:UpdatePanel ID=upnlTransfers runat=server UpdateMode=Always>
  4. <ContentTemplate>
  5. <asp:GridView ID="gvFundIn" runat="server" AllowSorting="True" ShowFooter=true DataSourceID="sdsTransfers" DataKeyNames="FundsIn_ID,Last_Update_Date,Follow_Up_Date" AutoGenerateColumns="False" Width="510px" >
  6. <Columns>
  7.  
  8. </Columns>
  9. <EmptyDataTemplate>
  10.  
  11.  
  12. </EmptyDataTemplate>
  13. </asp:GridView>
  14. <asp:Panel ID="pnldvFundInActions" runat=server>
  15. <br />
  16. <div align=center>
  17. <asp:Button ID="btnTIPending" runat="server" Width="215px" cssclass="input_btn_db" Text=" Transfer In Pending Items " OnCommand="btnPndItm_Click" CommandName="FundsIn" />
  18. <br />
  19. </div>
  20. <br />
  21. <div align=center>
  22. <asp:Button ID="btnTIPrvCmt" runat="server" Width="215px" cssclass="input_btn_db" Text="Add Transfer In Comments " OnCommand="btnPrvCmt_Click" CommandName="FundsIn" />
  23. </div>
  24. </asp:Panel>
  25. </asp:Panel>
  26. <asp:SqlDataSource
  27.  
  28. </asp:SqlDataSource>
  29. </ContentTemplate>
  30. </asp:UpdatePanel>
  31. </asp:Panel>
  32. </asp:panel>
  33.  
  34. Protected Sub btnPndItm_Click(ByVal sender As Object, ByVal e As CommandEventArgs) Handles btnPndItm.Command
  35. If Not e.CommandName = "" Then
  36. sdsPndItm.SelectParameters("TYPE").DefaultValue = CType(e.CommandName, String)
  37. Else
  38. sdsPndItm.SelectParameters("TYPE").DefaultValue = "Account"
  39. End If
  40. If Not e.CommandArgument = "" Then
  41. sdsPndItm.SelectParameters("SecondID").DefaultValue = CType(e.CommandArgument, Integer)
  42. Else
  43. sdsPndItm.SelectParameters("SecondID").DefaultValue = CType(Session("AcctID"), Integer)
  44. End If
  45. sdsPndItm.DataBind()
  46. Panel2.Visible = False
  47. pnlPndItm.Visible = True
  48. 'If Session("GroupID") = 4 Then
  49. gvPndItm.Columns(0).Visible = True
  50. 'Else
  51. ' gvPndItm.Columns(0).Visible = False
  52. 'End If
  53. End Sub
  54.  
  55. Protected Sub btnPrvCmt_Click(ByVal sender As Object, ByVal e As CommandEventArgs) Handles btnPrvCmt.Command
  56. If Not e.CommandName = "" Then
  57. SqlDataSource5.SelectParameters("TYPE").DefaultValue = CType(e.CommandName, String)
  58. Session("PrvCmtType") = CType(e.CommandName, String)
  59. Else
  60. SqlDataSource5.SelectParameters("TYPE").DefaultValue = "Account"
  61. Session("PrvCmtType") = "Account"
  62. End If
  63. If Not e.CommandArgument = "" Then
  64. Session("SecondID") = CType(e.CommandArgument, Integer)
  65. Else
  66. Session("SecondID") = CType(Session("AcctID"), Integer)
  67. End If
  68. SqlDataSource5.DataBind()
  69. Panel2.Visible = False
  70. pnlPrvCmt.Visible = True
  71. End Sub
  72.  
  73. protected override void OnInit(EventArgs e)
  74. {
  75. var scriptManager = ScriptManager.GetCurrent(this);
  76. // or this.Page in a UserControl, etc.
  77.  
  78. scriptManager.RegisterPostBackControl(someButton);
  79. scriptManager.RegisterPostBackControl(someOtherButton);
  80. // etc. for each control that needs to update something outside the UpdatePanel
  81. }
Add Comment
Please, Sign In to add comment