Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Dear All,

I have to display a popup when user clicks on Place button inside a Gridview and please remember it that as user clicks the Place button, I have to capture the value of commandArgument in a module level variable so that I can update it in Database.

Now as and when page displays and user clicks the Place button the page Postback to server and then popup appears and at the same time I capture the value of commandargument of button in code behind.

But, after the first click that is from 2nd time click of button displays the popup without sending the page on server.

That is it's not firing the onClick event of Place button and the value in module level variable remains unchanged.

After that if user selects Ok button from popup it updates the value which sets in the module level variable when the Place button called at first.

Please help me what should I do?

Is there any mistake in my code?
ASP.NET
<GridView id= "Grd"  runat="server" AutoGenerateColumns="false" CssClass="GridStyle" 
           HeaderStyle-Font-Size="Small" Width="960" Visible="false">
          <columns>          

          'Columns goes here          
          <asp:TemplateField HeaderText="Action" HeaderStyle-Width="310px" ItemStyle-HorizontalAlign="Left">
          <itemtemplate>
              <asp:Button ID="btnDelete" runat="server" Text="Delete" OnClick="btnDelete_Click" 
              CommandArgument='<%#Eval("intHireEnquiryID") %>' />
              <asp:Button ID="btnPlace" runat="server" Text="Place" OnClick="btnPlace_Click"  
              CommandArgument='<%#Eval("intHireEnquiryID") %>' />
              <ajaxtk:ModalPopupExtender  runat="server" ID="actPopup" TargetControlID="btnPlace" 
              PopupControlID="pnlPopup" CancelControlID="btnCancel" >
              
          </itemtemplate>
          
          </columns>   

In Panel I have two buttons PlaceFinal and Cancel which are used to Finally place and cancel the request.

In Code Behind i call it as : -
VB
Dim popup As New AjaxControlToolkit.ModalPopupExtender
        Dim i As Integer
        For i = 0 To Grd.Rows.Count - 1
            popup = Grd.Rows(i).FindControl("actPopup")
            popup.Show()
        Next
        pnlPopup.Visible = True


Please help me.

Is there any problem in ajax or i have to add any attribute to fire the event of Place button click?

Please help.
Any one please help.

I could not get any solution please help.
Posted
Updated 30-Nov-11 0:38am
v6
Comments
RaisKazi 30-Nov-11 2:34am    
Edited: 1) Formatting 2) Added "pre" tag.
Gopal Krishna Ranjan 30-Nov-11 3:08am    
Anyone Please help me.

Hi,

1)Dont Assign Modalpopup to button name "Place"..

2)Take another Button as Dummy button Apply Extender to it then ...


3)In Gridview Row Command Event...
<pre lang="c#">
  
Gridview_Row_Command_Event()
{
   
if (e.CommandName == "place")
        {
           

            Button1_ModalPopupExtender.Show();
 
        }
}
 
Share this answer
 
Comments
Gopal Krishna Ranjan 30-Nov-11 4:50am    
Dear Tushar, Please explain it so that i can use it in my source.
I took another button and set TargetControlId of extender to this new button id. Now what i have to do could not understand.
please help.
Thanx
<gridview id="Grd" runat="server" autogeneratecolumns="false" cssclass="GridStyle">
HeaderStyle-Font-Size="Small" Width="960" Visible="false">
<columns>

'Columns goes here
<asp:templatefield headertext="Action" headerstyle-width="310px" itemstyle-horizontalalign="Left" xmlns:asp="#unknown">
<itemtemplate>
<asp:button id="btnDelete" runat="server" text="Delete" onclick="btnDelete_Click">
CommandArgument='<%#Eval("intHireEnquiryID") %>' />
<asp:button id="btnPlace" runat="server" text="Place" onclick="btnPlace_Click">
CommandArgument='<%#Eval("intHireEnquiryID") %>' />








Remove the modalpopupextender which was taken inside gridview and keep it in an update panel like below and remember remove the TargetControlId of modalpopupextender from actual button to a dummy button which has no use on the page and hide it. This btnDummy is only to remove the bug of raising error when targetcontrolid is not defined for modalpopup and nothing.


<asp:updatepanel id="upPopupPnl" runat="server" updatemode="Conditional" xmlns:asp="#unknown">
<contenttemplate>
<asp:panel runat="server" id="pnlPopup" width="300px" height="300px" backcolor="Azure">
style="overflow:auto;border-color:Black;border-style:solid;border-width:2px;">
<asp:radiobuttonlist id="rbl1" runat="server">

<asp:button id="btnPlacePopup" runat="server" text="Place" width="100" height="35" font-bold="true">
OnClick="btnPlacePopup_Click" />
<asp:button id="btnCancel" runat="server" text="Cancel" width="100" height="35" font-bold="true">


<asp:button id="btnDummy" runat="server" text="Not Display" style="display:none;">
<ajaxtk:modalpopupextender id="actPopup1" runat="server" targetcontrolid="btnDummy" backgroundcssclass="modalBackground" xmlns:ajaxtk="#unknown">
PopupControlID="pnlPopup" CancelControlID="btnCancel">





The Css class is as: -

.modalBackground
{
background-color:#B3B3CC;
opacity:0.5;
}


Code behind: -

dim intHireEnquiryIDas integer
Protected Sub btnPlace_Click(ByVal sender As Object, ByVal e As System.EventArgs)
intHireEnquiryID = CType(sender, Button).CommandArgument
Dim EXP As New Exception
Dim params(0) As SqlParameter
params(0) = New SqlParameter("@intHireEnquiryID", intHireEnquiryID)
Dim DS As New DataSet
DS = execQuery("spAgent_Get_Assigned_Workers", executionType.SPExecuteForDS, EXP, params)
If DS.Tables(0).Rows.Count > 0 Then
rbl1.DataSource = DS
rbl1.DataTextField = "WorkerDetail"
rbl1.DataValueField = "intWorkerID"
rbl1.DataBind()
End If
upPopupPnl.Update()
actPopup1.Show()
End Sub


Thus it works great and fine.
points to remember: -
But remember to remove the TargetControlId of modalpopupextender from actual button to a dummy button which has no use on the page and hide it. And do not set visible property of panel which has to show to true or false. It will handle automatically by ajaxmodalpopupextender.
Actually why i took a dummy button as targetcontrolid of modalpopup because i need to postback the page partially to update the generated list of radiobuttons. but if we take the main button as targetcontrolid then the default behaviour of button will be overridden by modalpopup extender and it will not postback the page. So, i took a dummy button. And on the actual button click event i generate the list and bind it to radiobuttonlist and then called the update method of update panel and then called the show method of modalpopup.

It's fine now....
Thanks to all who tried to help me.
Thanks a lot!!
 
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