EnableEvenValidation to false on a .ascx

Last post 08-07-2009 3:49 AM by Monalisa1. 3 replies.

Sort Posts:

  • EnableEvenValidation to false on a .ascx

    07-05-2009, 3:21 AM
    • Member
      4 point Member
    • savior14
    • Member since 07-01-2009, 7:25 AM
    • Posts 15

    is there a way to turn this off on a .ascx?

    afaik its only for aspx. and the alternative way is setting it off on web.config.
    but in my situation i cannot do that, it'll affect all the pages on the project im on.

    there's also another way that ive read on a blog is using the "RegisterForEventValidation". but using this, you need to register all the POSSIBLE VALUES that a user can input. (thats totally insane) tried this but, but as ive said, need to register all the possible values. so this is no use.

            Protected Overrides Sub Render(ByVal writer As HtmlTextWriter)
                For j As Integer = 0 To Session("grdSubCore").Items.Count - 1
                    For i As Integer = 0 To Session("grdSubCore").Items.Item(j).FindControl("grdSkillsets").Items.Count - 1
                        Dim lblskillid As Label = DirectCast(Me.Session("grdSubCore").Items.Item(j).FindControl("grdSkillsets").Items.Item(i).FindControl("lblskillid"), Label)
                        Page.ClientScript.RegisterForEventValidation(lblskillid.UniqueID, lblskillid.Text)
                        Dim txtYear As TextBox = DirectCast(Session("grdSubCore").Items.Item(j).FindControl("grdSkillsets").Items.Item(i).FindControl("txtYear"), TextBox)
                        Page.ClientScript.RegisterForEventValidation(txtYear.UniqueID, txtYear.Text)
                        Dim txtMonth As TextBox = DirectCast(Session("grdSubCore").Items.Item(j).FindControl("grdSkillsets").Items.Item(i).FindControl("txtMonth"), TextBox)
                        Page.ClientScript.RegisterForEventValidation(txtMonth.UniqueID, txtMonth.Text)
                        Dim txtWeek As TextBox = DirectCast(Session("grdSubCore").Items.Item(j).FindControl("grdSkillsets").Items.Item(i).FindControl("txtWeek"), TextBox)
                        Page.ClientScript.RegisterForEventValidation(txtWeek.UniqueID, txtWeek.Text)
                        Dim txtDay As TextBox = DirectCast(Session("grdSubCore").Items.Item(j).FindControl("grdSkillsets").Items.Item(i).FindControl("txtDay"), TextBox)
                        Page.ClientScript.RegisterForEventValidation(txtDay.UniqueID, txtDay.Text)
                        Dim cbAble As CheckBox = DirectCast(Session("grdSubCore").Items.Item(j).FindControl("grdSkillsets").Items.Item(i).FindControl("cbAble"), CheckBox)
                        Page.ClientScript.RegisterForEventValidation(cbAble.UniqueID, cbAble.Text)
                        Dim imgUpdate As ImageButton = DirectCast(Session("grdSubCore").Items.Item(j).FindControl("grdSkillsets").Items.Item(i).FindControl("ImageButton2"), ImageButton)
                        Page.ClientScript.RegisterForEventValidation(imgUpdate.UniqueID, imgUpdate.AlternateText)
                    Next
                Next
                Page.ClientScript.RegisterForEventValidation(Me.Page.UniqueID)
                Dim upgrdSubCore As UpdatePanel = DirectCast(FindControl("upgrdSubCore"), UpdatePanel)
                Page.ClientScript.RegisterForEventValidation(upgrdSubCore.UniqueID)
                Dim UpdatePanelSkillsets As UpdatePanel = DirectCast(FindControl("UpdatePanelSkillsets"), UpdatePanel)
                Page.ClientScript.RegisterForEventValidation(UpdatePanelSkillsets.UniqueID)
                Dim dgSubCore As DataGrid = DirectCast(FindControl("grdSubCore"), DataGrid)
                Page.ClientScript.RegisterForEventValidation(dgSubCore.UniqueID)
                'Dim dgSkillset As DataGrid = DirectCast(dgSubCore.FindControl("grdSkillsets"), DataGrid)
                'Page.ClientScript.RegisterForEventValidation(Session("grdSkillset").UniqueID.ToString())
                Dim btnSave As Button = DirectCast(FindControl("btnSave"), Button)
                Page.ClientScript.RegisterForEventValidation(btnSave.UniqueID, btnSave.Text)
                Dim label3 As Label = DirectCast(FindControl("Label3"), Label)
                Page.ClientScript.RegisterForEventValidation(label3.UniqueID, label3.Text)
                Dim btnCancel As Button = DirectCast(FindControl("btnCancel"), Button)
                Page.ClientScript.RegisterForEventValidation(btnCancel.UniqueID, btnCancel.Text)
                MyBase.Render(writer)
            End Sub

    errr, ive got alot of textboxes on nested datagrids on a datagrid ~.~.


    anything i can to make this possible? like setting it on web.config but for a certain page only? i also cant turn it off using Page.EnableEventValidation = False on page init, it says i need to set it on page directively. (T_T)

    any help pls? help is very very much appreciated. tnx!


  • Re: EnableEvenValidation to false on a .ascx

    07-08-2009, 8:30 AM
    Answer
    • Contributor
      7,266 point Contributor
    • sirdneo
    • Member since 12-16-2008, 5:45 AM
    • Karachi, Pakistan
    • Posts 1,141

    I personally recommended that do not disable event validation. If you want to disable event validation, ensure that no postback could be constructed that could have an unintended effect on your application.

    Also if you have multple controls on your page , you can't set EnableEventValidation for individual controls.


    This error generally comes when you modify the contents of page using javascripts, such as add new values in combobox using javascript. Try to figure out why the problem is comming.

    Thanks,
    Zeeshan Umar

    ~Please Mark As Answer, if one or multiple posts, which helped you in your problem. So that it might be useful for others~

    My Blog
  • Re: EnableEvenValidation to false on a .ascx

    07-08-2009, 8:40 AM
    Answer
    • Star
      11,839 point Star
    • shahed.kazi
    • Member since 07-09-2008, 2:15 AM
    • Sydney, Australia
    • Posts 2,328

    You will need to disable this from the page that is using the use control. Add this in the page declaration.

    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="_Default" EnableEventValidation="false"  %>

  • Re: EnableEvenValidation to false on a .ascx

    08-07-2009, 3:49 AM
    • Member
      26 point Member
    • Monalisa1
    • Member since 08-05-2008, 5:44 AM
    • Bhubaneswar, India
    • Posts 9

    I had the same issue and it is fixed now.

    I was using update panel with update mode="conditional" in my page and also having trigeer thn that update panel.

    Previously i was having enable viewstate="false' for update panel.When i make it true (or removed it ) then the page worked very nicely

    No Need to disable EnableEventValidation. As this not safe to use.

    Thanks

    Sathyan
Page 1 of 1 (4 items)