This is a migrated thread and some comments may be shown as answers.

Problem clearing values in table

3 Answers 53 Views
Ajax
This is a migrated thread and some comments may be shown as answers.
cyfirst
Top achievements
Rank 1
cyfirst asked on 19 Dec 2009, 12:08 AM
Hi,
I'm having a problem clearing the values within a table and hoped for some input.  I have a table with values that can be entered by the user.  I also have a clear button, that when clicked executes javascript to set the value to "".  I've added a RadAjaxManager proxy to update the table when the clear button is clicked.  My problem is that the whole table disappears not just the values.  Can you tell me what I am doing wrong? 

<

 

asp:Table ID="IndexTable" runat="server" EnableViewState="false" >

 

 

</asp:Table>

 

 

<

 

asp:Button ID="btnClear" runat="server" Text="Clear" Width="85px"

 

 

    style="text-align:center;vertical-align:middle;margin-left:10px" 

 

    OnClientClick="ClearIndexData();" />  

 

<

 

telerik:RadScriptBlock ID="RadScriptBlock1" runat="server">

 

<script type="text/javascript" >

 

function ClearIndexData() {  

 

      
            //repository  
            repo = document.getElementById("ctl00_MainContent_hfRepoHint").innerText;  
 
            //custom indexes  
            for (i = 1; i <= 20; i++) {  
                if (document.getElementById("ctl00_MainContent_radIndex" + i.toString() + "S") != null) {  
                    if (repo.charAt(0) == '5')  
                        document.getElementById("ctl00_MainContent_radIndex" + i.toString() + "S").value = "";  
                    else  
                        document.getElementById("ctl00_MainContent_radIndex" + i.toString() + "S").value = "";  
 
 
                }  
                else if (document.getElementById("ctl00_MainContent_radIndex" + i.toString() + "R") != null) {  
                    if (repo.charAt(0) == '5')  
                        document.getElementById("ctl00_MainContent_radIndex" + i.toString() + "R").value = "";  
                    else  
                        document.getElementById("ctl00_MainContent_radIndex" + i.toString() + "R").value = "";  
 
                }  
            }  
        } 

 

</script>
</telerik:RadScriptBlock>

 

 

 

 


And here is the RadAjaxManager proxy settings
<telerik:RadAjaxManagerProxy ID="RadAjaxManagerProxy1" runat="server">  
 <AjaxSettings> 
     <telerik:AjaxSetting AjaxControlID="btnClear">  
         <UpdatedControls> 
             <telerik:AjaxUpdatedControl ControlID="IndexTable" /> 
         </UpdatedControls> 
     </telerik:AjaxSetting> 
 </AjaxSettings> 
</telerik:RadAjaxManagerProxy> 
Thanks in advance for any advice you can give me.
Chris

3 Answers, 1 is accepted

Sort by
0
Daniel
Telerik team
answered on 23 Dec 2009, 04:08 PM
Hello Cyfirst,

Please modify your Button as shown below:
<asp:Button ID="btnClear" runat="server" Text="Clear" Width="85px" Style="text-align: center; vertical-align: middle; margin-left: 10px" OnClientClick="ClearIndexData(); return false;" />

I hope this helps.

Kind regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
cyfirst
Top achievements
Rank 1
answered on 23 Dec 2009, 04:15 PM
Hi Daniel,
I tried that but it does not update the table then and the values are not cleared out.  I can do it via server code and rebuild the table but since I am only clearing the values, I thought it would be more efficient to just set value to "" via client script.  Any idea why the value would not be updated? 
Thanks,
0
Daniel
Telerik team
answered on 30 Dec 2009, 09:30 AM
Hello Chris,

If I understand your scenario properly, the Table is created dynamically in code-behind. Please note that, in such cases, you should recreate the Table on each postback.

Let me know if I'm missing something.

Kind regards,
Daniel
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
Ajax
Asked by
cyfirst
Top achievements
Rank 1
Answers by
Daniel
Telerik team
cyfirst
Top achievements
Rank 1
Share this question
or