Click here to Skip to main content
15,885,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello Sir/Madam,

I want to fire click event programmatically so i use Attribute event as i written below

((Button)grdEmpwiseAtt.Rows[index].FindControl("btnDetails")).Attributes.Add("onclick", "OpenChild('GetLog')");

when i click on button, event get fire but pop up will not be open so i need to click once again to open popup window.
How can i solve the issue, i want it on a single click

Reply
Thanks in advance,
yogesh Kansete
Posted
Comments
Faisalabadians 25-Jun-13 3:59am    
where is the code for popup opening?
yogeshkansete 25-Jun-13 5:09am    
I wrote this code to open popup

<script type="text/javascript" language="javascript">
function OpenChild(param) {
var value = param;
//var WinSettings = "center:yes;resizable:no;dialogHeight:200px;dialogWidth:200px"
//ALTER BELOW LINE - supply correct URL for Child Form
var MyArgs = window.showModalDialog('../Pages/Popupwindow.aspx?param=' + value);

}
</script>
Ingo 25-Jun-13 5:11am    
Well, the code for the PopUp would be good to see.
My first thought was: It openes but not in the front but in the back. Could that be possible?
yogeshkansete 25-Jun-13 5:25am    
If it is opened at back then how to show it on front.
But when i press button twice it has to open in centre

1 solution

on First click attribute add and second click it fire.


use it on a page load. or before this (((Button)grdEmpwiseAtt.Rows[index].FindControl("btnDetails")).Attributes.Add("onclick", "OpenChild('GetLog')");) event which u fire
 
Share this answer
 
Comments
yogeshkansete 25-Jun-13 6:10am    
actually this button is placed in gridview and i fired the RowCommand event so it is not posiible to write on page load event.
My rowcommand code is like this:
protected void grdEmpwiseAtt_RowCommand(object sender, GridViewCommandEventArgs e)
{
// this event fire to find index of selected row
if (e.CommandName.Equals("Details"))
{
DataSet ds = (DataSet)Session["ShiftStatus"];
string emp_IN = "";
string emp_OUT = "";
string Shift_StartClockInTime = "";
string Shift_EndClockInTime = "";
string Shift_StartClockOutTime = "";
string Shift_EndClockOutTime = "";
string ShiftFlag = "";
int index = Convert.ToInt32(e.CommandArgument); //get index of selected row
GridViewRow grd = grdEmpwiseAtt.Rows[index];
string empId = grd.Cells[0].Text.ToString();
Label lbl = (Label)grd.Cells[3].FindControl("lblShiftCode");
string ShiftCode = lbl.Text;
DataSet dsgetshifttimerange = obj_com.GetOneRecord("PAY_ShiftMaster", "CompCode='" + lblcompany.Text.Trim() + "' and ShiftCode='" + ShiftCode.ToString() + "' and Month='" + lblmonthno.Value.ToString() + "' and Year='" + lblYear.Text.Trim() + "'");
if (dsgetshifttimerange.Tables[0].Rows.Count > 0)
{
for (int i = 0; i < dsgetshifttimerange.Tables[0].Rows.Count; i++)
{
DateTime Shift_StartClockIn = Convert.ToDateTime(dsgetshifttimerange.Tables[0].Rows[i][6].ToString());
DateTime Shift_EndClockIn = Convert.ToDateTime(dsgetshifttimerange.Tables[0].Rows[i][7].ToString());
DateTime Shift_StartClockOut = Convert.ToDateTime(dsgetshifttimerange.Tables[0].Rows[i][9].ToString());
DateTime Shift_EndClockOut = Convert.ToDateTime(dsgetshifttimerange.Tables[0].Rows[i][10].ToString());
ShiftFlag = dsgetshifttimerange.Tables[0].Rows[i][3].ToString();

Shift_StartClockInTime = Shift_StartClockIn.ToShortTimeString(); //clockin_start_Time
Shift_EndClockInTime = Shift_EndClockIn.ToShortTimeString(); //clockin_end_Time

Shift_StartClockOutTime = Shift_StartClockOut.ToShortTimeString();//clockout_Start_Time
Shift_EndClockOutTime = Shift_EndClockOut.ToShortTimeString(); //clockout_End_Time
}
}
else
{

}
string Date = grd.Cells[2].Text.ToString();
string dd = Date.Substring(0, 2);
string mm = Date.Substring(3, 2);
string year = Date.Substring(6, 4);
DateTime date = Convert.ToDateTime(mm + "/" + dd + "/" + year);
//DateTime date = Convert.ToDateTime(Date);
string[] dtOfINT = grd.Cells[5].Text.ToString().Split(' ');
string[] dtofOUT = grd.Cells[6].Text.ToString().Split(' ');

DateTime InTime = Convert.ToDateTime(dtOfINT[0] + " " + Shift_StartClockInTime.ToString());
DateTime OutTime = Convert.ToDateTime(dtofOUT[0] + " " + Shift_EndClockOutTime.ToString());
string inFlag = ShiftFlag.Substring(0, 1);
string outFlag = ShiftFlag.Substring(1, 1);
//get log details
DataSet dsGetDetailsLog = obj_com.DetailsLog(lblcompany.Text.Trim(), empId.ToString(), lblmonthno.Value.ToString(), lblYear.Text.Trim(), date, InTime, OutTime, inFlag.ToString(), outFlag.ToString());
if (dsGetDetailsLog.Tables[0].Rows.Count > 0)
{
Session["GetDetailsLog"] = dsGetDetailsLog.Tables[0];
P
saurabh_ 26-Jun-13 1:17am    
Use RowdataBound in grid view
when data bind in grid view then attribute add to that button.

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