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

Validation controls and client side events

3 Answers 102 Views
ToolBar
This is a migrated thread and some comments may be shown as answers.
Akhil Raj
Top achievements
Rank 1
Akhil Raj asked on 08 Jun 2010, 05:27 AM
hi all,

I have a page to enter some details in database. For update i have save button in the radtoolbar. I already discussed in one of my thread regarding confirm box  when press save button. As per the answer i put onbuttonclicking client event and ask for confirmation and set_Cancel of the args to true if they press cancel in the confirmation box. All working fine.

Now i implemted validation controls including reuired fdield validator and custom validator to check the mandatory field and check any duplicate name entered. Here i need to ask the confirmation box after all this validation done only. But now before validation the confirm asking.

In the clientbuttonclicking i just checked whether the inputbox ahve any value and give confirm so i can bypass the confirm box when user not entered the name. But now need to control in the custom validation also. The custom validation checks for database table so i called serverside event to validatite duplication . Now i need a common solution for this. I just ask the confirmation after all this validation simply telling if page.isvalid only i need to ask the confirmation. How can i achieve this?

3 Answers, 1 is accepted

Sort by
0
T. Tsonev
Telerik team
answered on 11 Jun 2010, 12:42 PM
Hi Akhil,

Using client-side confirmation is not an option as you need server-side validation. My suggestion is to split the form in two parts - data entry and confirmation. You'll then have a chance to validate the data after entry.

For example:
http://demos.telerik.com/aspnet-ajax/tabstrip/examples/applicationscenarios/wizard/defaultcs.aspx

I hope this helps.

Sincerely yours,
Tsvetomir Tsonev
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
Akhil Raj
Top achievements
Rank 1
answered on 12 Jun 2010, 01:17 PM
hi admin,
  i read the sample. But my project requirement like all pages have common toolbar with close button and other button. So i cant change the behaviour. So can you please give any work around for this..
0
Akhil Raj
Top achievements
Rank 1
answered on 14 Jun 2010, 07:35 AM
hi admin,
 
    I have a work around. but i dont is it correct way or not. anyway i will tell my idea, not yet worked some issues in that also. I think you can help me in this.

Before please be confirm that any method to cancel the post back explicetly i means from any other conttrol or event?

Please check the folllwing code in my save button (which is in rad toolbar)

    Protected Sub rtb_Controls_ButtonClick(ByVal sender As ObjectByVal e As Telerik.Web.UI.RadToolBarEventArgs) Handles rtb_Controls.ButtonClick  
        Try 
            Dim btn As RadToolBarButton = TryCast(e.Item, RadToolBarButton)  
            If btn.CommandName = "Save" Then 
                If Page.IsValid Then 
                    If hfMessage.Value = "true" Then 
 
                        'insert function here  
                   End If 
                    ClientScript.RegisterStartupScript(Me.GetType(), "a""<script type='text/javascript'>check();</script>")  
 
                End If 
            End If 
        Catch ex As Exception  
            PlaceHolder1.Controls.Add(ErrorMsg.TryCatchErrorDisplay(ex.Message.ToString(), True))  
        End Try 
    End Sub 
 

Through this i check if the page is valid. then i need to insert. before insert only i need to confirm save from client side confirm box. Here i have an idea. Actually my confirm box message is coming from resource file. So that i saved the message in one hidden field called 'hfMessage'.

CleintSript.RegisterCleintSideScript is not working here... So i just started with checking hiddenfield
Befoe insert i can check when the hfmessage value is original message or "true" (this value i will set later). So first time i will get original message so skip the insert funtion . Then called the registerstartup script. This function give the popup and set the user clicked value in the hfMessage field and called the AjaxRequest event. Please check the following javascript...

            function check() {  
                var hf = document.getElementById("<%= hfMessage.ClientID %>");  
                if (confirm(hf.value) != true) {  
                    hf.value = "false";  
                }  
                else {  
                    hf.value = "true";  
                }  
                $find("<%= RadAjaxManager1.ClientID %>").ajaxRequest("alert");  
            }  
 
So that from the ajax_Request event i can check the hfMessage value and insert and close the window. I dont know is this a good idea. Please sugggest about this.
But the main issue i am facing here is i didnt got the ajaxmanager1 in the check event. Only null returned...

I need to solve the scenario so please suggest or give any other idea




Tags
ToolBar
Asked by
Akhil Raj
Top achievements
Rank 1
Answers by
T. Tsonev
Telerik team
Akhil Raj
Top achievements
Rank 1
Share this question
or