StringBuilder html = new StringBuilder();
html.Append("<table>");
html.Append("<tr>");
html.Append("<td>");
//You can use an <a></a> instead of <linkbutton>
html.Append("<a id='lnkbtn1' name = '123' onclick='test(this)' > Accept</a>");
html.Append("</td>");
html.Append("</tr>");
html.Append("</table>");
PlaceHolder1.Controls.Add(new Literal { Text = html.ToString() });
Get the attribute and call model popup :
function test(obj) {
var currentOrderID = $(obj).attr('name');
alert(currentOrderID);
// Call model popup
openmodalaccept();
}
Then try to use HtmlTable control as shown above code sample . or use jquery ajax call server side function to store id in session , then call modal popup .
Member
15 Points
50 Posts
put the dynamic link button into html.append
Oct 16, 2016 03:34 PM|motorrevo00|LINK
i have code behind like this
html.append("<table>");
html.append("<tr>");
html.append("<td>");
html.append("</td>");
html.append("</tr>");
html.append("</table>");
PlaceHolder1.Controls.Add(new Literal { Text = html.ToString() });
and
LinkButton likbt = new LinkButton();
likbt.Text = "Accept";
likbt.ID = "lnkbtn"+row["id_order"];
likbt.CommandArgument = row["id_order"].ToString();
likbt.Attributes.Add("UseSubmitBehavior", "false");
likbt.Command += likbt_Click;
how to put the linkbutton into between tag <td></tr>
All-Star
18815 Points
3831 Posts
Re: put the dynamic link button into html.append
Oct 17, 2016 07:44 AM|Nan Yu|LINK
Hi motorrevo00,
You could use HtmlTable control :
or use html <a> tag :
Best Regards,
Nan Yu
Member
512 Points
182 Posts
Re: put the dynamic link button into html.append
Oct 17, 2016 07:46 AM|Sagar Kamate|LINK
You can do this using table class Or HTMLtable class.
refer the below code using Table.
Sagar Kamate, Software Engineer.
sagark_1008@yahoo.co.in
Don't forget to Mark this thread as "Answer", if it was useful to you.
Member
15 Points
50 Posts
Re: put the dynamic link button into html.append
Oct 17, 2016 08:26 PM|motorrevo00|LINK
how to add command argument in tag a href ?
try to write this code :
html.Append("<a UseSubmitBehavior='false' OnClick='likbt_Click' CommandArgument=");
html.Append(row["id_order"].ToString());
html.Append(" >Accept</a>");
protected void likbt_Click(object sender, CommandEventArgs e)
{
Session["id_order"] = e.CommandArgument ;
ScriptManager.RegisterStartupScript(this, this.GetType(), "Pop", "openmodalaccept();", true);
}
but when i'm clicking nothing happen
if, use select button the code work .. but i prefer to use us an <a></a>
thanks before Nan Yu
All-Star
18815 Points
3831 Posts
Re: put the dynamic link button into html.append
Oct 18, 2016 09:37 AM|Nan Yu|LINK
Hi motorrevo00,
You could record id in name attribute of a tag :
Get the attribute and call model popup :
Best Regards,
Nan Yu
Member
15 Points
50 Posts
Re: put the dynamic link button into html.append
Oct 18, 2016 03:17 PM|motorrevo00|LINK
i'm planning when the a href is click then the id set session and open the modal .. so, i want running code behind
Thank You Nan Yu
All-Star
18815 Points
3831 Posts
Re: put the dynamic link button into html.append
Oct 19, 2016 01:19 AM|Nan Yu|LINK
Hi ,
Then try to use HtmlTable control as shown above code sample . or use jquery ajax call server side function to store id in session , then call modal popup .
Best Regards,
Nan Yu
Member
15 Points
50 Posts
Re: put the dynamic link button into html.append
Oct 21, 2016 03:38 AM|motorrevo00|LINK
so hard =( , so i use repeter control to show data and add link button ..
Thank Nan Yu