Developer forum

Forum » Development » RE: UpdatePanel problems.

RE: UpdatePanel problems.

Yasharth Tahiliani
Reply

Hi,

I'm developing a User Control for a website wherein I want to use an UpdatePanel to automatically update the contents of dropdown lists when a value in one list is chosen.

I have tried, but it isn't just working :( 

When I open up the browser debugger console, it throws an internal server 500 error.

I am attaching a copy of my ascx file. 

Has anyone faced similar problems while trying to implement UpdatePanel user controls with Dynamic Web?

Any help will be very appreciated.

Thanks.


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Hi there,

Have you seen this: http://devierkoeden.com/articles/custom-functionality-using-user-controls.aspx ?

Imar

 
Yasharth Tahiliani
Reply

Hi Imar,

Yes, I have followed your post to create User Controls on the website. The funny thing is that the User Control works locally on my machine but when I embed it to the template as a User Control on the website, it doesn't seem to work.

Very strange.

Here is the ascx code:

 

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="Search.ascx.cs" Inherits="Search" Debug="true" %>
<form runat="server">
    <asp:ScriptManager EnablePartialRendering="true" ID="ScriptManager1" runat="server"></asp:ScriptManager>
<%--    <script type="text/javascript" lange="javascript">
        Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);
        function EndRequestHandler(sender, args){
        if (args.get_error() != undefined){
            args.set_errorHandled(true);
        }
    }
    </script>--%>
    <div class="clearfix logo">
        <div class="container">
            <a href="/"><img class="hide-on-scroll-50 no-mobile" src="/Files/Templates/Designs/Condition/assets/images/design/nst-logo-banner.png" /></a>
        </div>
    </div>
    <!--Filter-->
    <asp:Label ID="errorLbl" runat="server"></asp:Label>
    <div class="tour-filter inactive col col-width-10">
         <h4 class="no-mobile">Filter your search - <span>please select one or more search criteria and click update</span></h4>
        <div class="columns">
           <asp:UpdatePanel ID="subjectUpdatePanel" runat="server">
           <ContentTemplate> 
            <asp:PlaceHolder ID="searchUpdateFilter" runat="server">
            <div class="col col-width-2">
                <div class="range-slider box price">
                    <label for="amount" class="style-as-paragraph">Price per person:</label>
                    <div class="slider"></div>
                    <input type="text" class="slider-field" id="amount" name="amount" readonly>
                </div>
            </div>

            <div class="col col-width-2">
                <div class="form-input select">
                <!-- <label for="subject" class="style-as-paragraph">Subject</label> -->
                    <div class="field">
                            <asp:DropDownList ID="subjectDD" runat="server" AutoPostBack="true" OnSelectedIndexChanged="subjectDD_SelectedIndexChanged" Enabled="true">
                                <asp:ListItem Text="Subject" Value="Subject"/>
                            </asp:DropDownList>

                    </div>
                </div>
            </div>
            <div class="col col-width-2">
                <div class="form-input select">
                    <!-- <label for="country" class="style-as-paragraph">Country</label> -->
                    <div class="field">
                         <asp:DropDownList ID="countryDD" runat="server" EnableViewState="true">
                             <asp:ListItem Text="Country" Value="Country"/>
                         </asp:DropDownList>
                    </div>
                </div>
            </div>
            <div class="col col-width-2">
                <div class="form-input select">
                    <!-- <label for="location" class="style-as-paragraph">Location</label> -->
                    <div class="field">    
                        <asp:DropDownList ID="destinationDD" runat="server">
                            <asp:ListItem Text="Destination" Value="Destination"/>
                        </asp:DropDownList>
                    </div>
                </div>
            </div>
            <div class="col col-width-2">
                <div class="form-input select">
                    <!-- <label for="audience" class="style-as-paragraph">Audience</label> -->
                    <div class="field">
                        <asp:DropDownList ID="schoolDD" runat="server">
                            <asp:ListItem Text="School type" Value="School type"/>
                        </asp:DropDownList>
                    </div>
                </div>
            </div>
            <div class="col col-width-2">
                <!-- temporary override in main.js -->
                <div class="form-input submit">
                    <input type="submit" value="Update">
                </div>
            </div>
            </asp:PlaceHolder>
           </ContentTemplate>
               <Triggers>
                   <asp:AsyncPostBackTrigger ControlID="subjectDD" EventName="SelectedIndexChanged" />
               </Triggers>
               </asp:UpdatePanel>             
        </div>
    </div>


</form>

 

If you could please help me with this, that would be great!

 

Thanks!

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

Can you provide more informaton? What error do you get? When you use a tool like Fiddler, do you see data going to the server?

Imar

 
Yasharth Tahiliani
Reply

Hi Imar,

I am attaching a screen shot of the page and the error that I get. As you can see at the bottom, it gives an Internal Server Error (500).

Please let me know if you need to know more about this.

I can provide you a link with the web page possibly.

Thanks & Regards,

Yash.

 
Yasharth Tahiliani
Reply

Here is the screenshot.

AJAXError.jpg
 
Yasharth Tahiliani
Reply

Could it be maybe because Ajax might not be installed on the server?

 
Yasharth Tahiliani
Reply

It is installed. When I run the user control on a simple test website with just one default.aspx page with the user control on the server, it works. 

It doesn't seem to be working with dynamic web. Can you please look into this?

Best Regards,

Yash.

 
Nicolai Høeg Pedersen
Reply

The page returning response code 500 must have an exception. What is the Exception?

 
Yasharth Tahiliani
Reply

Server Error in '/' Application.


Object reference not set to an instance of an object.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.

Source Error:

 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.


Stack Trace:
 

[NullReferenceException: Object reference not set to an instance of an object.]
   Dynamicweb.Database.SqlInjectionPrevent() +307
   Dynamicweb.Frontend.GlobalAsaxHandler.Application_OnPreRequestHandlerExecute(Object sender, EventArgs e) +1471
   System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +91
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +164
 
Yasharth Tahiliani
Reply

This is the response..

 
Nicolai Høeg Pedersen
Reply

Hi Yasharth

That indicates, that your callback in AJAX does not have a http context. Maybe because it is a ashx callback? You might want to take a look at this:

http://stackoverflow.com/questions/14181408/httpcontext-current-session-is-null-in-ashx-file

 
Yasharth Tahiliani
Reply

Hi Nicolai, thanks for your message. 

I fail to understand what the problem could be. I am not aware of any ashx files?

When I implement this user control in a simple web site, it works. But it doesn't for some reason with the Dynamic Web solution.

I think this could be a bug in the CMS that it doesn't support Update Panels, or maybe I am doing something really silly.

Hope we can find a solution to this very soon!

 

You must be logged in to post in the forum