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

[Solved] Suppress ClientEvents on Page_Load

3 Answers 164 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Michael
Top achievements
Rank 1
Michael asked on 30 Oct 2009, 12:57 PM
Hello!

I have an ASP.NET-Button shipped with VS. This button is responsible for saving the data the user enters in the form. When the Page is loaded, the button should be disabled. Then I have other controls (standard VS controls), where I have "linked" the client-side onpropertychange() event. When a user for example fills out a javascript-enabled textbox, the javascript-function will enable the Save-Button. Everything is fine.

When I now - for example - use RadTextBox and link the ClientEvents-OnValueChanged with the same javascript-function, the page loads and I can see, that the Save-Button is automatically enabled?!?

Is it possible, that RadControls do not fire javascript-events on Page_Load? Are there any workarounds?

Bye

Michael

3 Answers, 1 is accepted

Sort by
0
Nikolay Rusev
Telerik team
answered on 02 Nov 2009, 02:55 PM
Hello Michael,

The code bellow will switch the Button control int enabled mode whenever you change the text of RadTextBox, not on initial load:
01.<form id="form1" runat="server">
02.    <asp:ScriptManager runat="server" ID="ScriptManager1"></asp:ScriptManager>
03.    <div>
04.    <telerik:RadTextBox runat="server" ID="Box1" >
05.        <ClientEvents OnValueChanged="function(){$get('Button1').disabled = '';}"/>       
06.    </telerik:RadTextBox>
07.      
08.    <asp:Button runat="server" ID="Button1" Text="Save" Enabled="false"/>
09.    </div>
10.    </form>

I hope this helps.

Regards,
Nikolay
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
Michael
Top achievements
Rank 1
answered on 02 Nov 2009, 04:26 PM
Hi!

Sorry, but it did not help. My code is nearly the same:

function

 

Aenderung() {

 

 

     obj = document.getElementById(

"<%= btSpeichernAktualisieren.ClientID %>");

 

 

     obj.disabled =

'';

 

 

 

}

...

 

 

 <

 

asp:Button ID="btSpeichernAktualisieren" runat="server" CommandArgument="Insert" OnCommand="btSpeichernAktualisieren_Command" Text="Speichern/Aktualisieren" Visible="false" />
==> the Button is set to Visible = true and Enabled = false in the Page_Load-Event
...
 <telerik:RadTextBox ID="rtbKapitel" runat="server" Skin="WebBlue" Width="100px"

 

 

    <ClientEvents OnValueChanged="Aenderung()" />

 <

 

/telerik:RadTextBox>
...
<asp:TextBox ID="TextBox1" runat="server" onchange="Aenderung()"></asp:TextBox


When I now load the page, the button "btSpeichernAktualisieren" is enabled?!?!? When I delete the code line  <ClientEvents OnValueChanged="Aenderung()" /> and I try again, the button is disabled after Page_Load!! As recently as I change the content of the TextBox1 and thisTextBox1 lost the focus, the Button btSpeichernAktualisieren gets enabled. This is the behaviour I also want by the Telerik-Controls!!!

Please help me!

Kind regards

Michael

 

 

 

 

0
Nikolay Rusev
Telerik team
answered on 05 Nov 2009, 11:19 AM
Hello Michael,

For your convenience I am attaching sample project utilizing the code from my last replay.
It demonstrates that "Changed" event will not be triggered until you change the value inside RadTextBox.

Regards,
Nikolay
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
General Discussions
Asked by
Michael
Top achievements
Rank 1
Answers by
Nikolay Rusev
Telerik team
Michael
Top achievements
Rank 1
Share this question
or