Click here to Skip to main content
16,017,151 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
In my application i want to call method on clicking of input button.the input button is created dynamically.The input button is created using response.write() in .aspx file.The code written by us is as follows:


XML
<body bgcolor="silver">
        <form id="form1" runat="server">
       <div>
            <%   string AdminId = Request.Params.Get("AdminId");
                string FirstName,LastName,EmailId,ClassName,FacultyName;
                 SqlConnection objsqlconnection = new SqlConnection();
                 objsqlconnection.ConnectionString = ("Data Source=.\\SQLEXPRESS;AttachDbFilename=G:\\Ujwala\\Project\\Student Community\\Student_Community\\Student_Community\\App_Data\\Stud_Community.mdf;Integrated Security=True;User Instance=True");
                 SqlCommand objsqlcommand = objsqlconnection.CreateCommand();
                 objsqlconnection.Open();
                 string SelectStudInfo = "SELECT tblStudent_Registration.FirstName, tblStudent_Registration.LastName,tblStudent_Registration.EmailId,tblClass_Info.ClassName,tblFaculty_Info.FacultyName FROM tblRequestApprove INNER JOIN tblStudent_Registration ON tblRequestApprove.StudId = tblStudent_Registration.StudId INNER JOIN tblClass_Info ON tblStudent_Registration.ClassId = tblClass_Info.ClassId INNER JOIN tblFaculty_Info ON tblStudent_Registration.FacultyId = tblFaculty_Info.FacultyId WHERE (tblRequestApprove.AdminId ='"+AdminId+"')";
                 objsqlcommand = objsqlconnection.CreateCommand();
                 objsqlcommand.CommandText = SelectStudInfo;
                 SqlDataAdapter sqldataadapter = new SqlDataAdapter(objsqlcommand);
                 DataTable datatable = new DataTable();
                 sqldataadapter.Fill(datatable);
                 int i = 0;
                 Response.Write("<b><font face='roman' size=3 color='red'>");
                 Response.Write("<Table border='1' height=40 width=800><tr><th>Name&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>EmailId&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>ClassName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th><th>FacultyName&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</th></tr></Table><br>");
                 Response.Write("</b></font>");
                 foreach (DataRow row in datatable.Rows)
                 {

                     FirstName = datatable.Rows[i]["FirstName"].ToString();
                     LastName = datatable.Rows[i]["LastName"].ToString();
                     EmailId = datatable.Rows[i]["EmailId"].ToString();
                     ClassName = datatable.Rows[i]["ClassName"].ToString();
                     FacultyName = datatable.Rows[i]["FacultyName"].ToString();
                     Response.Write("<table border='1' height=60 width=800><tr><td>");
                     Response.Write("<a href='DisplayStudInfo.aspx?AdminId="+AdminId+"&EmailId="+EmailId+"'><b><font color='blue'>" + FirstName + "" + LastName + "</font></b></a>");
                     Response.Write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                     Response.Write("<b><font size=4 color='black'>");
                     Response.Write(EmailId);
                     Response.Write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                     Response.Write(ClassName);
                     Response.Write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                     Response.Write(FacultyName);

                     Response.Write("&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;");
                     Response.Write("<form><input type='Button' value='Approve' name='BtnSubmit' nbsp;&nbsp;<input type='Button' value='Reject' name='BtnReject' /form>");
                     Response.Write("</b></font>");
                     Response.Write("</td></tr></table>");
                     Response.Write("<br>");
                    i++;
                 }
                objsqlconnection.Close();
               %>
        </div>
        </form>
    </body>




I want to execute method on click of input submit button.
How can I achieve this?Please help me.
Thanks.
Posted

Hi,

You've to give form action property to activate input action .


try that.It can works for you.


All the best
 
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