473,394 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Validation in Ajax updatepanel - not working

112 100+
Hello there...

can somebody guide me on this…

I have a panel (say, panel1) inside another panel (say, outer-panel)….The panel1 is visible only when a checkbox is checked in the outer-panel. I am using ajax update panel to do this.

Now I have many text boxes in the panel1. I have to put a validation on all the boxes.

I tried to test this by putting validation on 2 boxes and this works fine on my local machine. When I put the same logic on the server, it does not. Of course the page on my local machine has fewer text boxes compared to the page on server. But I do not understand why the same logic works on my local machine and does not work on the server. I did try to put a validation group, but of no use....

The page on the sever is a very long one and also it has a captcha control….. when ever I try not to enter text in one the text boxes which has validation and then hit submit…it redirects me to another page with out prompting for the validation error.

Can somebody please tell me what could be the reason…thanks in advance….
Mar 15 '10 #1
12 8591
Frinavale
9,735 Expert Mod 8TB
Did you register your validation JavaScript with the ScriptManager?

If you didn't you're going to run into problems where the JavaScript validation will execute as long as no asynchronous postback has been made to the server....after an asynchronous postback has happened then the previously working JavaScript will no longer work. That is one of the reasons why the ScriptManager exists, so that you can register your JavaScript in order for it to be sent to every time the page is asynchronously loaded to keep scripts working.

-Frinny
Mar 16 '10 #2
user1980
112 100+
thank you for your response..I did register the script with the scriptmanager...but still I have this problem...
Mar 16 '10 #3
Frinavale
9,735 Expert Mod 8TB
How did you register the script?
(Please post the code that registers the script with the ScriptManager)

-Frinny
Mar 17 '10 #4
user1980
112 100+
I am just using,
<asp:ScriptManager ID="ScriptManager1" runat="server" />

And then using the udpatepanel to display the panel conditionally......
Mar 17 '10 #5
Frinavale
9,735 Expert Mod 8TB
That is the declaration of the ScriptManager....
Did you actually register the validation script with ScriptManager??

See the ScriptManager class for a list of the ScriptManager Methods available to you.

-Frinny
Mar 17 '10 #6
user1980
112 100+
I have many textboxes and validations fot eh text boxes in my updatepanel ContentTempalte..so do I have to register all of them thought the script manager...I have seen the example in the page http://msdn.microsoft.com/en-us/libr...ptmanager.aspx.but I am not sure how would i register my components....so can you please let me know if there is any other reference that I can look into....thanks you for your time...
Mar 17 '10 #7
Frinavale
9,735 Expert Mod 8TB
This really depends on how you are doing your validation.

I'm not sure how you are calling or using the JavaScript.
If you have implemented some JavaScript that does the validation, and you have your button's client onclick event call this JavaScript, then all you have to do is register that script with the ScriptManager.

-Frinny
Mar 17 '10 #8
user1980
112 100+
Hi Frinny

I am not suing any additional javascript. For all the textboxes in the panel, I am enabling the validations in pageload...as,
Expand|Select|Wrap|Line Numbers
  1.     protected void Page_Load(object sender, EventArgs e)
  2.         {
  3.  
  4.             if (gpa.Text != "")
  5.             {
  6.  
  7.                 required_classgpa.Enabled = true;
  8.                 required_classgpa.SetFocusOnError = true;
  9.  
  10.  
  11.             }
  12.             else
  13.             {
  14.                 required_classgpa.Enabled = false;
  15.             }
  16.             if (classgpa.Text != "")
  17.             {
  18.                 required_gpa.Enabled = true;
  19.                 SetFocus(gpa);
  20.             }
  21.             else
  22.             {
  23.                 required_gpa.Enabled = false;
  24.             }
  25.  
  26.             if (classrank.Text != "")
  27.             {
  28.                 required_totalclass.Enabled = true;
  29.             }
  30.             else
  31.             {
  32.                 required_totalclass.Enabled = false;
  33.             }
  34.  
  35.             if (totalclass.Text != "")
  36.             {
  37.                 required_classrank.Enabled = true;
  38.             }
  39.             else
  40.             {
  41.                 required_classrank.Enabled = false;
  42.             }
  43.  
  44.  
  45.         }
  46. ...
so in my case do I still have to register the script, then how would I register ??

I have tried replicating a similar scenario with fewer elements and that page works fine with out any issues....I am clueless on why this is happening...
Mar 17 '10 #9
Frinavale
9,735 Expert Mod 8TB
You should have mentioned before that you are not using JavaScript validation. That you are doing your validation on the server in your C# code.

The only thing that I can think of is if the elements that you are trying to work with are not inside the UpdatePanel that performed the asynchronous postback.

If you have a label in UpdatePanelA and a TextBox in UpdatePanelB. If UpdatePanelB performs the asynchronous postback you cannot access the label in UpdatePanelA if UpdatePanelA was not inside UpdatePanelB.

You can access the label in your C# code during the asynchronous postback but it will not be updated when the page is redrawn in the browser since ASP.NET strips down the response to only include the elements that were part of the asynchronous postback.

Does that make sense?
Mar 17 '10 #10
user1980
112 100+
thank you for the response......i have label and text boxes in the same panel...so that could not be the reason.

You can access the label in your C# code during the asynchronous postback but it will not be updated when the page is redrawn in the browser since ASP.NET strips down the request to only include the elements that were part of the asynchronous postback.
...this could be the possible reason...
but still one thing is not clear...as mentioned earlier, I did try to replicate a test page with 2 update panels and similar validations and they work fine...just when the no:of elements in the page increase, the validations fail...
Mar 17 '10 #11
Frinavale
9,735 Expert Mod 8TB
I'm not sure what to suggest....

Double check your logic for the case when you add more elements.

-Frinny
Mar 17 '10 #12
user1980
112 100+
thank you for all the help.. I will look into logic...
Mar 17 '10 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Nobody | last post by:
I have an aspx page where I have a repeater control that repeats a asp:LinkButton. When I click on one of the links, I get a post back, and the page flashes. A friend told me to look into ATLAS/AJAX,...
4
by: bbawa1 | last post by:
When I add updatePanel control in my aspx page it gives me following error. Unknown server tag 'ajax:UpdatePanel
10
by: =?Utf-8?B?WWFua2VlIEltcGVyaWFsaXN0IERvZw==?= | last post by:
controlsPlease could some of you here post some of your live examples of AJAX (esp drag panels, collapsable panels, and popup menu.) (It's one thing to talk about how great something is, but it's...
2
by: =?Utf-8?B?VG9u?= | last post by:
Hello, I want to understand teh benefits of ajax technology. Does anyone has a good website where AJAX EXTENSIONS is worked out so I really understand it. There a 2 main questions: 1) How about...
7
by: MikeB | last post by:
Hello All, I am new to ajax and wanted to start by trying something simple. I have a web form with an updatepanel and then inside the update panel I have a listbox. Then outside of the updatepanel...
4
by: Peter | last post by:
ASP.NET I have an application which use ASP.NET Autocomplete extender which works great. But I have a question how to update all the fields on the screen using Ajax. Users starts typing in a...
4
by: foolmelon | last post by:
Before AJAX, we were able to focus a cell in a gridview during a fullpage postback. After putting the gridview inside an UpdatePanel, we cannot focus a cell in this gridview anymore. Does anybody...
1
by: nRk | last post by:
Hi, I am working on asp.net 2.0 with Visual Studio 2005. My asp.net project contains one Masterpage. I exposed my asp.net project in my machine (Windows XP with IIS 5.1) and access using...
1
by: raam | last post by:
Hi, I have ajax tab container with 6 tabs in it. I need to validate each tab contents separately and the validtaion summary must be separate for each tab. i cannot do that only one summary is...
4
by: Peter | last post by:
ASP.NET 2.0 I have an AutoCompleteExtender which works fine- I am using name, id pair in the WebService , but what I am trying to do is: once the user selects an item from the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.