onclick is not working
-
I want to create a switch button to turn on and off status. the problem is this button should be inside a repeater. I dont know how to change on to off and how to pass the the required parameter to save the changes to DB. The following code is not working and also it is not complete. here is HTML code :
<asp:Repeater ID="RptRulesAndAlerts" runat="server"
onitemdatabound="RptRulesAndAlerts_ItemDataBound" >
<SeparatorTemplate>
<br />
</SeparatorTemplate>
<ItemTemplate><tr valign="middle">
<td width="20%" align="center" valign="middle">
<asp:Panel ID="pnl_status" runat="server" ></asp:Panel>
</td>
</tr>
</table>
</asp:Panel>
</div></ItemTemplate>
</asp:Repeater>I am adding the switch button in code behind:
protected void RptRulesAndAlerts_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem )
{
ISRulesAndAlertsDisplay display = e.Item.DataItem as ISRulesAndAlertsDisplay;Panel pnl_status = e.Item.FindControl("pnl_status") as Panel;
if (display.Status < 0) //show default Rule
{
HyperLink showDefaultpops = new HyperLink();
showDefaultpops.NavigateUrl = "#";
showDefaultpops.Text = GetLocalResourceObject(display.StatusDescription).ToString();
showDefaultpops.ID = "libtn_DefaultRule";
pnl_status.Controls.Add(showDefaultpops);
}
else //show the switch button
{
var div=new HtmlGenericControl("div");
div.Attributes["class"]=string.Format("OnOff {0}",(display.Status==1)?"ON" :"OFF" );
div.Attributes["Title"] = string.Format("Click Here to {0}", (display.Status == 1) ? "OFF" : "ON");var span = new HtmlGenericControl("span"); span.Attributes\["class"\]="on"; span.InnerText="ON"; div.Controls.Add(span); if (display.Status == 0) span.Style\["display"\] = "none"; span = new HtmlGenericControl("span"); di
-
I want to create a switch button to turn on and off status. the problem is this button should be inside a repeater. I dont know how to change on to off and how to pass the the required parameter to save the changes to DB. The following code is not working and also it is not complete. here is HTML code :
<asp:Repeater ID="RptRulesAndAlerts" runat="server"
onitemdatabound="RptRulesAndAlerts_ItemDataBound" >
<SeparatorTemplate>
<br />
</SeparatorTemplate>
<ItemTemplate><tr valign="middle">
<td width="20%" align="center" valign="middle">
<asp:Panel ID="pnl_status" runat="server" ></asp:Panel>
</td>
</tr>
</table>
</asp:Panel>
</div></ItemTemplate>
</asp:Repeater>I am adding the switch button in code behind:
protected void RptRulesAndAlerts_ItemDataBound(object sender, RepeaterItemEventArgs e)
{
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType==ListItemType.AlternatingItem )
{
ISRulesAndAlertsDisplay display = e.Item.DataItem as ISRulesAndAlertsDisplay;Panel pnl_status = e.Item.FindControl("pnl_status") as Panel;
if (display.Status < 0) //show default Rule
{
HyperLink showDefaultpops = new HyperLink();
showDefaultpops.NavigateUrl = "#";
showDefaultpops.Text = GetLocalResourceObject(display.StatusDescription).ToString();
showDefaultpops.ID = "libtn_DefaultRule";
pnl_status.Controls.Add(showDefaultpops);
}
else //show the switch button
{
var div=new HtmlGenericControl("div");
div.Attributes["class"]=string.Format("OnOff {0}",(display.Status==1)?"ON" :"OFF" );
div.Attributes["Title"] = string.Format("Click Here to {0}", (display.Status == 1) ? "OFF" : "ON");var span = new HtmlGenericControl("span"); span.Attributes\["class"\]="on"; span.InnerText="ON"; div.Controls.Add(span); if (display.Status == 0) span.Style\["display"\] = "none"; span = new HtmlGenericControl("span"); di