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

Javascript error in radwindow from radgrid

3 Answers 60 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Chad Johnson
Top achievements
Rank 1
Chad Johnson asked on 14 Oct 2008, 01:33 PM
Greetings,

So, the problem I'm having right now is an odd one, or at least to me.  I have a page with a RadGrid in it, that has it's editmode turned to popup that calls a control of mine.  Upon the window appearing, I get a javascript error.  This error comes from some javascript that I'm trying to add within a radToolBar.  Here is what I have.

<script type="text/javascript">  
    function onClientButtonClick(sender, args)  
    {  
        var btn = args.get_item();  
        if (btn.get_commandName() == "PerformInsert")  
        {  
            var txt = $find("ctl00_ctl00_cphContent2_cphAITContent_rgdComments_ctl00_ctl02_ctl03_EditFormControl_txtComment_text");  
            var temp = txt.value.replace('/^\s+|\s+$/g', '');  
            if (temp.value.length == 0)  
            {  
                alert("You must enter text in order to add/edit your comment.");  
            }  
        }  
    }  
</script> 
 
<telerik:RadToolBar ID="rtbCommentText" runat="server" OnButtonClick="rtbCommentText_ButtonClick" 
        OnClientButtonClicked="onClientButtonClick">  
        <Items> 
            <telerik:RadToolBarButton CommandName="PerformInsert" Text="Save" SkinID="SaveBtn">  
            </telerik:RadToolBarButton> 
            <telerik:RadToolBarButton CommandName="Cancel" Text="Cancel" SkinID="CancelBtn">  
            </telerik:RadToolBarButton> 
        </Items> 
    </telerik:RadToolBar> 
    <br /> 
    <telerik:RadTextBox ID="txtComment" runat="server" TextMode="MultiLine" Width="500px" Height="250px">  
    </telerik:RadTextBox> 

Prior to adding the javascript codeblock, the page worked, but I need to check txtComment to find out if it has anything in itself or not on the clientside so I can do an alert.  Is there a way to do this?  Thanks.

Chad

3 Answers, 1 is accepted

Sort by
0
Iana Tsolova
Telerik team
answered on 16 Oct 2008, 01:49 PM
Hello Chad,

What does the error message says?

Please try wrapping your script block in RadCodeBlock for instance and check if it makes any difference.

Let me know how it goes.

All the best,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Chad Johnson
Top achievements
Rank 1
answered on 16 Oct 2008, 03:21 PM
That didn't really help.  The error I receive is the following:

A Runtime Error has occured.
Line 198790271
Error: 'onClientButtonClick' is undefined

I looked at the line of code, but it's all gibberish really within IE it looked like.
0
Iana Tsolova
Telerik team
answered on 17 Oct 2008, 12:23 PM
Hello Chad,

Thank you for providing details.

In such case I suggest that you place the script directly on the page with the grid and check if it helps. Another option is to move the script in a separate js file and register the script on Page_Load in the user control:

protected void Page_Load(object sender, EventArgs e)  
{  
    ScriptManager.RegisterClientScriptInclude(Page,typeof(Page),   
        "EditFormClientScript""scripts.js");  

Sincerely yours,
Iana
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
Grid
Asked by
Chad Johnson
Top achievements
Rank 1
Answers by
Iana Tsolova
Telerik team
Chad Johnson
Top achievements
Rank 1
Share this question
or