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

radprompt callback bug

3 Answers 89 Views
Grid
This is a migrated thread and some comments may be shown as answers.
Daniel
Top achievements
Rank 1
Daniel asked on 12 Sep 2008, 12:27 PM
Interesting behavior in the radprompt function of the RadWindowManager.  If you submit a callback function name with no argument, like callbackfn it works fine, firing on the button click of the radprompt window, However, if you add an argument to the callback function (like callbackfn(this))  it fires on the radprompt LOAD event, not the callback...  Any ideas on how to fix this?

thanks,
-Daniel

3 Answers, 1 is accepted

Sort by
0
Georgi Tunev
Telerik team
answered on 12 Sep 2008, 01:30 PM
Hi Daniel,

This is not a bug - radprompt accept the name of the callback function only, not the function itself and you cannot pass arguments like that.

Would you please provide more details about your exact setup and what you want to achieve?


Best wishes,
Georgi Tunev
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
0
Daniel
Top achievements
Rank 1
answered on 12 Sep 2008, 02:24 PM

I created a Imagebutton control (for editing a text comment field) that is built as a class and can be added to a gridTemplateColumn with bindable properties. This button calls radPrompt by taking the values of the properties and assembling them into a radPrompt call command that fires on the "onClick" event of the button.   I was hoping to get the data back out of the prompt by using the event args passed to the javascript, but if this fires on load, then the data has not been changed at that point.

help? 

here's the class for the button:

Imports

System.Web.UI.WebControls

Imports

System.Web.UI

Imports

System.ComponentModel

Public

Class CommentButton

Inherits ImageButton

 

Private _comment As String

Private _radTitle As String

Private _radText As String

Private _callbackFunction As String

Public Sub New()

MyBase.New()

MyBase.ImageUrl = "../images/commentoff.gif"

End Sub

Public Sub New(ByVal comment As String)

MyBase.New()

MyBase.ImageUrl = "../images/commenton.gif"

_comment = comment

End Sub

'The underlying property is a string, and returns a string.. so why they felt the need to put an error on this????

<System.Diagnostics.CodeAnalysis.SuppressMessage(

"Microsoft.Design", "CA1056:UriPropertiesShouldNotBeStrings")> _

Public Shadows ReadOnly Property ImageUrl() As String

Get

Return MyBase.ImageUrl

End Get

End Property

Public Shadows Property AlternateText() As String

Get

Return MyBase.AlternateText

End Get

Set(ByVal value As String)

MyBase.AlternateText = value

End Set

End Property

Public Property Comment() As String

Get

Return _comment

End Get

Set(ByVal value As String)

_comment = value

If Not _comment = Nothing And _comment <> "" Then

MyBase.ImageUrl = "../images/commenton.gif"

End If

End Set

End Property

Public Property PromptTitle() As String

Get

Return _radTitle

End Get

Set(ByVal value As String)

_radTitle = value

End Set

End Property

Public Property PromptText() As String

Get

Return _radText

End Get

Set(ByVal value As String)

_radText = value

End Set

End Property

Public Property CallbackFunctionString() As String

Get

Return _callbackFunction

End Get

Set(ByVal value As String)

_callbackFunction = value

End Set

End Property

Protected Overrides Sub AddAttributesToRender(ByVal writer As System.Web.UI.HtmlTextWriter)

' radprompt(Text, callBackFn, oWidth, oHeight, callerObj, oTitle, defaultValue)

writer.AddAttribute(

"Comment", _comment)

writer.AddAttribute(

"OnClick", "radprompt('" & _radTitle & "', testme(this), 500, 150,null, '" & _radText & "', '" & _comment & "'); return false;")

MyBase.AddAttributesToRender(writer)

End Sub

End

Class

0
Georgi Tunev
Telerik team
answered on 16 Sep 2008, 02:30 PM
Hello Daniel,

In your scenario, I suggest to set only the name of the function in the OnClick eventhandler along with the arguments that you wish to pass to that function.

Here is how to read the arguments in the callbackFn:

function promptDialog(text,title,defvaule,btn) 
    function callbackFn() 
    { 
        //this way you can have direct access to the arguments of the promptDialog() function 
    } 
    radprompt(text,callbackFn,500,150,null,title,defvalue);  


Greetings,
Georgi Tunev
the Telerik team

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