Click here to Skip to main content
15,887,214 members
Home / Discussions / Web Development
   

Web Development

 
QuestionHow to get data from the other website in php Pin
surendra4u20-Mar-13 0:32
surendra4u20-Mar-13 0:32 
AnswerRe: How to get data from the other website in php Pin
dusty_dex20-Mar-13 3:03
dusty_dex20-Mar-13 3:03 
AnswerRe: How to get data from the other website in php Pin
dusty_dex22-Mar-13 5:28
dusty_dex22-Mar-13 5:28 
AnswerRe: How to get data from the other website in php Pin
Josh Houghtelin26-Jul-13 20:53
Josh Houghtelin26-Jul-13 20:53 
QuestionAjax library for webworkers Pin
Sebastiaan Meijerink13-Mar-13 7:15
professionalSebastiaan Meijerink13-Mar-13 7:15 
AnswerRe: Ajax library for webworkers Pin
dusty_dex13-Mar-13 7:38
dusty_dex13-Mar-13 7:38 
GeneralRe: Ajax library for webworkers Pin
Sebastiaan Meijerink13-Mar-13 22:01
professionalSebastiaan Meijerink13-Mar-13 22:01 
Questiononclick is not working Pin
Nafiseh Salmani12-Mar-13 13:48
Nafiseh Salmani12-Mar-13 13:48 
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.NET
<pre><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:

C#
 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;
<pre> 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");
                    div.Controls.Add(span);
                   
                    span = new HtmlGenericControl("span");
                    span.Attributes["class"]="off";
                    span.InnerText="OFF";
                    if (display.Status == 1) span.Style["display"] = "none";
                    div.Controls.Add(span);
                    div.Attributes["id"] = "div_status";
                   
                    pnl_status.Controls.Add(div);
                    div.Attributes.Add("OnClick", string.Format("toggle({0});",div.ClientID ));
                   // pnl_status.Attributes.Add["OnClick"]= string.Format(" <%# SaveStatus({0},{1},{2})%> ",display.RuleAlertID,display.Status,e.Item.ItemIndex); 
                }





Neither the toggle function nor the function in codebehind is working(I commented the part of codebehind function)


and here is the javascript part

JavaScript
<pre><script type="text/javascript" >
        
        $(document).ready(function(){
        
        function toggle(id) {
            var element = document.getElementById(id);
            if ($(element).hasClass('On')) {
                $('.on', this).hide();
                $('.off', this).show();
                $element.addClass('Off').removeClass('On').attr('title', 'Click here to OFF');
            }
            else {
                $('.off', this).hide();
                $('.on', this).show();
                $element.addClass('On').removeClass('Off').attr('title', 'Click here to ON');

            }
            alert("END");
        }  })
      
    </script>





Even the Alert is not working , I wrote it there to see if the toggle is calling. I really need to have both javascript and the commented function for onclick works. what should I do?
I am pretty beginner in javascript.
GeneralRe: onclick is not working Pin
ZurdoDev13-Mar-13 1:59
professionalZurdoDev13-Mar-13 1:59 
QuestioniOS webapp with offline appcache. How to create authenticated wcf service call. Pin
Sebastiaan Meijerink12-Mar-13 12:32
professionalSebastiaan Meijerink12-Mar-13 12:32 
Questionsend username and password safely Pin
Member 982605211-Mar-13 19:03
Member 982605211-Mar-13 19:03 
QuestionPost a comment (message ) on my web page Pin
kryptong9-Mar-13 23:04
kryptong9-Mar-13 23:04 
AnswerRe: Post a comment (message ) on my web page Pin
dusty_dex10-Mar-13 6:59
dusty_dex10-Mar-13 6:59 
Questionwhere to place JavaScript Pin
hrishi3219-Mar-13 21:18
hrishi3219-Mar-13 21:18 
AnswerRe: where to place JavaScript Pin
dusty_dex10-Mar-13 7:09
dusty_dex10-Mar-13 7:09 
SuggestionWeb Development Pin
Taqi_Shah7-Mar-13 22:07
Taqi_Shah7-Mar-13 22:07 
AnswerRe: Web Development Pin
jkirkerx8-Mar-13 13:07
professionaljkirkerx8-Mar-13 13:07 
QuestionMCPD......VS...... MCSD ......VS...... MCAD Pin
Hercal7-Mar-13 0:27
Hercal7-Mar-13 0:27 
AnswerRe: MCPD......VS...... MCSD ......VS...... MCAD Pin
Richard MacCutchan7-Mar-13 1:41
mveRichard MacCutchan7-Mar-13 1:41 
AnswerRe: MCPD......VS...... MCSD ......VS...... MCAD Pin
ZurdoDev13-Mar-13 3:00
professionalZurdoDev13-Mar-13 3:00 
QuestionAbout SELECT MULTIPLE in HTML Pin
michel066-Mar-13 19:25
michel066-Mar-13 19:25 
AnswerRe: About SELECT MULTIPLE in HTML Pin
Sandeep Mewara7-Mar-13 2:54
mveSandeep Mewara7-Mar-13 2:54 
AnswerRe: About SELECT MULTIPLE in HTML Pin
ZurdoDev13-Mar-13 3:02
professionalZurdoDev13-Mar-13 3:02 
QuestionLinking to another application and displaying the application data Pin
civic0606-Mar-13 6:30
civic0606-Mar-13 6:30 
AnswerRe: Linking to another application and displaying the application data Pin
ZurdoDev13-Mar-13 3:03
professionalZurdoDev13-Mar-13 3:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.