Category Archives: ScriptManagerProxy

ScriptManagerProxy

[RESOLVED]POP UP window like panel not wrking

Hi,

In my page i have designed two ModalPopupExtender.They wrked well wen i used script mngers.

I used script mngr in master page so i removed that one in the current child page.

But that is not wrking.I have also used Script Mngr Proxy but its not wrking.

PL HLP 2 resolve it..

thnks,

Download the Demo program from this link program name in ModelpopupExtender

https://skydrive.live.com/?lc=24841#cid=2F22272220E37707&id=2F22272220E37707%21103

Hi,

You have placed a ScriptManagerProxy or ToolkitManagerProxy in your aspx page and Also if you are working with .Net 4.0 then you might want to specify AjaxFrameworkMode="Enabled"

If your ModalPopupExtender in the masterpage inside UpdatePanel and your UpdatePanel UpdateMode="conditoinal" you have to change it to always , or use Update() method.

Refer the following Link………

http://www.velocityreviews.com/forums/t633729-modalpopupextender-and-scriptmanager-asyncpostbackerror-event.html

Hopes Helps U……………………..

The PopupPanel and the TargetControl should be placed in the same page with the ModalPopupExtender. But we can open a Modal from another page by using the Server side code:

ModalPopupExtender1.Show();//the ModalPopupExtender1 is the ID.

Client side code: $find(“the ModalPopupExtender’s behaviorId”).show();

You can also refer to these threads about how to use the ModalPopup with Master Page:
http://forums.asp.net/p/1315032/2606428.aspx#2606428
http://forums.asp.net/p/1368988/2861595.aspx#2861595
http://forums.asp.net/p/1439413/3263860.aspx#3263860

http://forums.asp.net/t/1368988.aspx/1

http://forums.asp.net/t/1379792.aspx/1

Hi,

Please try to use ToolkitScriptManager instead of ScriptManager. Any more question, please feel free to reply.

i have used loading panel and its wrking fine.I loading panel i didnt used any triggers.Without triggers its working good.

Mine is asp.net 3.5 framework in c#.net.

thnks 2 all folks

[RESOLVED]Modal Popup Extender is not working

Hi all,

Trying to make a panel pop up with a modal popup extender. Have done it many times but now for some reason this one is not working.

Here’s the code:

<%@ Page Title="" Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="docmanager.aspx.vb" Inherits="documents_docmanager" %>

<%@ Register assembly="CuteEditor" namespace="CuteEditor" tagprefix="CE" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" Runat="Server">
  
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" Runat="Server">
    <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
    
    </asp:ScriptManagerProxy>

 <asp:LinkButton ID="lbshowupload" runat="server" Text = "Upload a file"
             />
            <act:ModalPopupExtender ID="mpe" runat="server"
        TargetControlID="lbshowupload" PopupControlID="pnlupload" CancelControlID="closebutton" OkControlID="btnAddFiles"
        BackgroundCssClass="dialog_background"></act:ModalPopupExtender>

    
    <div class="searchlistings">
     <asp:HiddenField ID="hfuid" runat="server" />
       



        <asp:SqlDataSource ID="dssections" runat="server"
            ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
            
            SelectCommand="SELECT DISTINCT sections.section_id, sections.sectionname, (SELECT COUNT(*) AS Expr1 FROM filesinsections WHERE (sections.section_id = section_id)) AS doc_count, aspnet_UsersInRoles.UserId FROM sections INNER JOIN aspnet_UsersInRoles INNER JOIN SectionsInRoles ON aspnet_UsersInRoles.RoleId = SectionsInRoles.RoleId ON sections.section_id = SectionsInRoles.section_id WHERE (sections.is_active = @is_active) AND (aspnet_UsersInRoles.UserId = @UserId) OR (sections.is_active = 1) AND (sections.section_id = 1)">
            <SelectParameters>
                <asp:Parameter DefaultValue="true" Name="is_active" />
                <asp:ControlParameter ControlID="hfuid" DefaultValue="" Name="UserId"
                    PropertyName="Value" />
            </SelectParameters>
        </asp:SqlDataSource>
       
        <asp:DataList ID="DLSectionDocs" runat="server"
            DataKeyField="section_id" DataSourceID="dssections" Width="100%"
            ShowFooter="true" BorderStyle="None" ShowHeader="true">

            <HeaderTemplate>
            <div class="searchresultssectionname">
                <asp:Label ID="Label6" runat="server" CssClass="title"
                    Text='<%# Eval("sectionname") %>'></asp:Label>
                    </div>
            </HeaderTemplate>
            <ItemTemplate>
                <asp:Label ID="Label8" runat="server" style="font-weight: 700"
                    Text='<%# Eval("sectionname") %>'></asp:Label>
                <asp:Label ID="Label7" runat="server" Text='<%# Eval("doc_count", "({0})") %>'></asp:Label>
                <asp:HiddenField ID="hfsectionid" runat="server"
                    Value='<%# Eval("section_id") %>' />
                <asp:SqlDataSource ID="dsdocs" runat="server"
                    ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                    SelectCommand="SELECT dm_files.file_id, dm_files.file_name, dm_files.date_uploaded, dm_files.file_type, dm_files.file_size, dm_files.downloadcount, dm_files.file_title, dm_files.keywords, dm_files.fileguid, filesinsections.section_id FROM dm_files INNER JOIN filesinsections ON dm_files.file_id = filesinsections.file_id WHERE (filesinsections.section_id = @section_id)">
                    <SelectParameters>
                        <asp:ControlParameter ControlID="hfsectionid" Name="section_id"
                            PropertyName="Value" />
                    </SelectParameters>
                </asp:SqlDataSource>
                <asp:UpdatePanel ID="upfilelist" runat="server">
                    <ContentTemplate>
                    
                <asp:GridView ID="gvfiles" runat="server" AllowPaging="True"
                    AutoGenerateColumns="False" BorderStyle="None" DataKeyNames="file_id"
                    DataSourceID="dsdocs" EmptyDataText="No Files Listed for this section"
                    PageSize="5" Width="100%" ShowFooter="false" GridLines="None" FooterStyle-CssClass="searchfootertemplate">
                    <Columns>
                        <asp:TemplateField HeaderText="" InsertVisible="False"
                            SortExpression="file_id">
                            <EditItemTemplate>
                                <asp:Label ID="Label1" runat="server" Text='<%# Eval("file_id") %>'></asp:Label>
                            </EditItemTemplate>
                            <ItemTemplate>
                                <asp:LinkButton ID="LinkButton1" runat="server"
                                    CommandArgument='<%# Bind("fileguid") %>' CssClass="searchfiletitle"
                                    Text='<%# Bind("file_title") %>' onclick="LinkButton1_Click"></asp:LinkButton>
                                &nbsp;<asp:Label ID="Label11" runat="server"
                                    Text='<%# Bind("file_type", "File Type: {0}") %>'></asp:Label>
                                <asp:Label ID="Label12" runat="server"
                                    Text='<%# Bind("file_size", " Size: {0} mb") %>'></asp:Label>
                                <br />
                                <asp:Label ID="Label13" runat="server" CssClass="sideeventsdate"
                                    Text='<%# Bind("downloadcount", "Downloaded {0} time(s) ") %>'></asp:Label>
                                &nbsp;<asp:Label ID="Label10" runat="server" CssClass="sideeventsdate"
                                    Text='<%# Eval("date_uploaded", "Uploaded On: {0:G}") %>'></asp:Label>
                                <br />
                                <asp:Label ID="Label9" runat="server" CssClass="searchfilekeywords"
                                    Text='<%# Eval("keywords", "Keywords: {0}") %>'></asp:Label>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                    <FooterStyle CssClass="searchfootertemplate" />
                </asp:GridView>
                </ContentTemplate>
                </asp:UpdatePanel>
                
            </ItemTemplate>
            <FooterTemplate><div style="margin-bottom: 15px;"></div></FooterTemplate>
        </asp:DataList>
    <br />

    <asp:Panel ID="pnlupload" runat="server" CssClass="modalpopup">
         <asp:Panel ID="addfiletitle" runat="server" CssClass="dialog_title">
            <div class="modalpopup_title"><asp:Image ID="closebutton" runat="server"
                    ImageUrl="~/images/closebutton.gif"
                    style="float:right;cursor:pointer;margin-right:5px;margin-top:5px;" />
            <div id="popuptitletext" style="text-align:center;">Upload Documents</div>
            </div>
      </asp:Panel>
  
       
      <div class="modalpopup_modalbody">
            <asp:Label ID="Label1" runat="server" Text="&lt;h1&gt;Upload File&lt;/h1&gt;"></asp:Label>
            <table style="width:100%;">
               
                <tr>
                    <td class="style1">
                        <asp:Label ID="Label2" runat="server" Text="File Title:" Font-Bold="True"></asp:Label>
                    </td>
                    <td>
                        &nbsp;</td>
                    <td>
                        <asp:TextBox ID="txttitle" runat="server" Width="380px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="style1">
                        <asp:Label ID="Label3" runat="server" Text="Keywords (Aids in file search)"
                            Font-Bold="True"></asp:Label>
                    </td>
                    <td>
                        &nbsp;</td>
                    <td>
                        <asp:TextBox ID="txtkeywords" runat="server" Width="380px"></asp:TextBox>
                    </td>
                </tr>
                <tr>
                    <td class="style1">
                        <asp:Label ID="Label5" runat="server" Font-Bold="True" Text="Section:"
                            ToolTip="The section this file is most associated with."></asp:Label>
                    </td>
                    <td>
                        &nbsp;</td>
                    <td>
                          <asp:DropDownList ID="ddldirectory" runat="server" DataSourceID="dsauthorizedpages"
                        DataTextField="sectionname" DataValueField="section_id" Width="380px">
                    </asp:DropDownList>
                    <asp:SqlDataSource ID="dsauthorizedpages" runat="server" ConnectionString="<%$ ConnectionStrings:ApplicationServices %>"
                        SelectCommand="SELECT        sections.sectionname, sections.section_id FROM            sectioneditorroles INNER JOIN                          aspnet_UsersInRoles ON sectioneditorroles.RoleId = aspnet_UsersInRoles.RoleId INNER JOIN                          sections ON sectioneditorroles.section_id = sections.section_id WHERE        (aspnet_UsersInRoles.UserId = @userid)">
                        <SelectParameters>
                            <asp:ControlParameter ControlID="hfuid" Name="userid" PropertyName="Value" />
                        </SelectParameters>
                    </asp:SqlDataSource>
                    </td>
                </tr>
                <tr>
                    <td class="style1">
                        &nbsp;</td>
                    <td>
                        &nbsp;</td>
                    <td>
                        <asp:CheckBox ID="CheckBox1" runat="server"
                            Text="Members Only? (Leave unchecked to make this file public.)" />
                    </td>
                </tr>
                <tr>
                    <td class="style1">
                        <asp:Label ID="Label4" runat="server" Font-Bold="True" Text="File:"></asp:Label>
                    </td>
                    <td>
                        &nbsp;</td>
                    <td>
                        <CE:UploadAttachments ID="Attachments1" runat="server"
                            FileTypeNotSupportMsg="Invalid File Type"
                            InsertText="Select A File To Upload..." MultipleFilesUpload="False"
                            ShowProgressInfo="False">
                            <ValidateOption AllowedFileExtensions="doc,docx,xls,xlsx,ppt,pptx,pdf,zip,mp3,mp4,jpg,gif,avi,mov,png,psd" />
                        </CE:UploadAttachments>
                    </td>
                </tr>
                <tr>
                    <td class="style1">
                       
                    </td>
                    <td>
                        &nbsp;</td>
                    <td>
                         <asp:Button ID="btnAddFiles" runat="server" Text="Add Files" />
                        &nbsp;<asp:Button ID="btnCancel" runat="server" Text="Cancel" Visible="False" /></td>
                </tr>
            </table>
                        <asp:ListBox runat="server" ID="ListBoxEvents" Width="380"></asp:ListBox>
        </div>
        
        </asp:Panel>
    </div>
    
</asp:Content>

I appreciate a fresh set of eyes on this and hopefully can point out what I’m missing.

Thanks all,

hi 

on your page i can’t see the ajax register assembly 

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="asp" %>

Hello,

The assembly is registered in the web.config file.

I got this to work by moving the modal and panels to the masterpage (it should be there anyway) and all of the panels that will be shown modally right before the </form> tag. 

This seemed to do the trick.

[RESOLVED]SlideShowExtender not working in production server

SlideShowExtender gets images list from webservice. This works fine on localhost in VS2008 but doesnot work on the production hosting server. Hosting is a shared hosting provider. I have tried a simple ‘Hello World’ webservice and this works fine in both
environments. The webservice is getting a list of image files from a folder in the website file system. i have been trawling google and forums for over a day now and while people have had problems no one has provided a solution. Output from the invoke button
in localhost is:

<ArrayOfSlide>
<Slide>
<ImagePath>../images/show/01_Clinic2.jpg</ImagePath>
<Name>01_Clinic2.jpg</Name>
<Description/>
</Slide>
<Slide>
<ImagePath>../images/show/02_banner_01.jpg</ImagePath>
<Name>02_banner_01.jpg</Name>
<Description/>
</Slide>
</ArrayOfSlide>

etc;

Does any one have any ideas? Where to start? It would be helpful if I could see the webservice output?

Thanks in advance.

Hi

If it is working locally then there will be problem image path. Please check that img path. or test with some hardcoded URL .

 

Thanks chandradev1 for replying

I have tried with the imagepaths hard coded and still does not work.
Do you know of a way that I can see what the output on the production environment is, so that I can see what image path it is serving?

The following is the webservice function thaty I am using, I can’t see any reason why it should be different to the local path.

<WebMethod()> _
    Public Function GetSlides() As AjaxControlToolkit.Slide()
        Dim imagenames As String() = System.IO.Directory.GetFiles(Server.MapPath("~/images/show"))
        Dim photos As AjaxControlToolkit.Slide() = New AjaxControlToolkit.Slide(imagenames.Length – 1) {}
        For i As Integer = 0 To imagenames.Length – 1
            Dim file As String() = imagenames(i).Split("")
            photos(i) = New AjaxControlToolkit.Slide("../images/show/" & file(file.Length – 1), file(file.Length – 1), "")
         Next
        Return photos
    End Function

code for the aspx file includes

<asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
    <Services>
    <asp:ServiceReference Path="~/WebServices/NameService.asmx" />
    <asp:ServiceReference Path="~/WebServices/ShowSlides.asmx" />
    </Services>
    </asp:ScriptManagerProxy>

 <asp:SlideShowExtender ID="sseHome" runat="server" AutoPlay="True" Loop="True"

                TargetControlID="imgSlides" SlideShowServiceMethod="GetSlides"
                PlayInterval="1000" SlideShowServicePath="~/WebServices/ShowSlides.asmx">
    </asp:SlideShowExtender>         
     <asp:Image ID="imgSlides" runat="server" Height="326" Width="830" ImageUrl="~/images/show/01_Clinic2.jpg" ImageAlign="Middle" />

Thanks

Hi,

Make sure you install the correct version of the AjaxControlToolkit:

Version 3.0.20229 2008-02-29 release of the AJAX Control Toolkit targets the official release of .NET Framework 3.5 and Visual Studio 2008.

Version 1.0.20229 You can also download the Toolkit for .NET Framework 2.0, ASP.NET AJAX 1.0 and Visual Studio 2005.

Version 3.0.40412

April 12, 2010 release of the AJAX Control Toolkit for ASP.NET 3.5 Service Pack 1 and Visual Studio 2008 SP1.

Version 4.1.51116.0

Nov 16 2011 release of the AJAX Control Toolkit for ASP.NET 4.0 and Visual Studio 2010

Then you could add the Ajax Control Toolkit to the VS Toolbox step by step at:http://www.asp.net/ajaxlibrary/act.ashx.

Hi

That can be surely a file reference issue. Check this post for some explanation-

http://forums.asp.net/p/1742058/4695188.aspx/1?Re+CSS+couldn+t+be+retrieve+

thanks
chetan.sarode

I have installed

.Net Framework 3.5 SP1
Visual Studio 2008 Pro SP1 (KB9451401)
AjaxControlToolkit.dll         File version: 3.5.50927.0

Hi

Yes, you can check like this, Type the path of Img folder on browser then you will get all images available in that folder. like this

http://localhost:51002/Frame_In_Asp/img/

Here i have kept for local machine.

If ajax other control is working fine on production server then there is no problem with ajax dll.

I m sure your problem is related with image path.

 

 

Hi all, thanks for your continued input.

I have consumed the output from GetSlides on Production Server into a gridview

these are what I expected (hardcoded in webservice for testing), so why does the SlideShowExtender not like these ImagePaths?
I have also check my local and production web.config files and they both are the same (except for the usually reconfigurations)
I hard coded the above imagepaths into a image container in the aspx page and they displayed fine.

I have deduced that Ajax Toolkit is not working, so I’ll pursue that line and come but to this post when I’ve resolved it.

Thanks to all.

Hi

In production server, what ever image URL you are getting, That image is not getting on server. So you have to give exact path, where the image is availabe on server.

For example

You have kept in Images folder then in subfolder show.

Then your path should be like this

http://yousitename.com/Images/show/1.jpg  then it will display on browser. You try to make your code dynamic in this formate

Hi all thanks for your inputs.

I deduced that the Ajax Control toolkit was not working properly. After reading numerous post elsewhere I added

EnablePartialRendering="true" CombineScripts="false" LoadScriptsBeforeUI="false"

to the <asp:ToolkitScriptManager tag
i.e.
<asp:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server" EnablePartialRendering="true" CombineScripts="false" LoadScriptsBeforeUI="false">
    </asp:ToolkitScriptManager>


and everything works perfectly. Apparently a bug in the Control Toolkit.

Cheers.

Gridview in Updatepanel + back button in .Net 2.0

Hi,

I have a gridview in the updatepanel,now after the data is populated in the grid through async postback,if i hit the back button of the browser the grid returns back to empty.

Anyone has a solution to diable the back button or nothing shoudl happen on the back button click.

Thanks

Abhishek

According to your description ,I would like to suggest you to check the links below for some articles which describe how to enable Back/Forward-Button Support for ASP.NET AJAX UpdatePanel.

http://weblogs.asp.net/scottgu/archive/2006/09/14/Tip_2F00_Trick_3A00_-Enabling-Back_2F00_Forward_2D00_Button-Support-for-ASP.NET-AJAX-UpdatePanel.aspx

http://www.codeproject.com/KB/aspnet/ajaxhistorymanagement.aspx?display=Print

On your ScriptManager, you need to set EnableHistory="true". Then, on the buttons that change from page1 to page 2 (to print page #3), you have to invoke ScriptManager.GetCurrent(Page).AddHistoryPoint("KeyName", value);

This saves the back button history state.

Now you have to override the OnNavigate event of the ScriptManager (or ScriptManagerProxy if your ScriptManager is in a MasterPage). When navigating, you have to restore the user’s previous state manually.

The default behavior of the back button is what you are seeing — it goes to the previous URL loaded in the browser. When you are using UpdatePanels, this URL doesn’t change.

There are a few tutorials about this, here is one:

http://geekswithblogs.net/ranganh/archive/2008/11/17/enabling-the-browserrsquos-back-button-for-grid-view-asp.net-ajax.aspx

You can also google against ScriptManager, EnableHistory, AddHistoryPoint, and OnNavigate.

Managing Browser History Using ASP.NET Server Controls

http://msdn.microsoft.com/en-us/library/cc488548.aspx

Hi Chetan,

Really Appreciate your reply.

But all these changes holds good for .net 3.5 not for .net 2.0.

Please let me know if any thing is possible to be done in .net 2.0

Thanks

Abhishek

Gridview redirect button and back button problem

My problem. I have an GridView inside an updatePanel. When I click in a button inside the gridview it redirects to another page. But when I click in back button in browser gets to the same page as before but with Session["Id"] changed. And it does PageLoad
when I click at any item inside the page. It there’s a way if I click back button that or redirect to first page or give me the same page as before with the same Sessions and not enter PageLoad??   thanks

//My ScriptManager
<asp:ScriptManager ID="ScriptManager1" runat="server" EnableHistory="true" EnableSecureHistoryState="false"
        EnablePartialRendering="true" OnNavigate="ScriptManager1_Navigate">
    </asp:ScriptManager>


//My update panel:
<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Always">

//My gridView:

 <asp:GridView ID="grid" runat="server" EnableModelValidation="true" AutoGenerateColumns="false"
                AllowPaging="true" PageSize="20" Width="100%" Font-Size="Smaller" OnRowDataBound="grid_RowDataBound"
                OnPageIndexChanging="grid_PageIndexChanging"
                OnRowCommand="grid_RowCommand">
                <HeaderStyle ForeColor="White" />
                <Columns>
                    <asp:BoundField HeaderText="Name" DataField="name">
                        <ItemStyle />
                    </asp:BoundField>
                    <asp:BoundField HeaderText="id" DataField="id">
                        <ItemStyle />
                    </asp:BoundField>
                    <asp:BoundField HeaderText="AnotherField" DataField="anotherField">
                        <ItemStyle />
                    </asp:BoundField>
                    <asp:BoundField HeaderText="AnotherField2" DataField="anotherField">
                        <ItemStyle />
                    </asp:BoundField>
                    <asp:TemplateField>
                        <ItemTemplate>
                            <asp:ImageButton ID="btnRedirect" runat="server" CommandArgument='<%#DataBinder.Eval(Container.DataItem,"id") %>' CommandName="redirect"
                                ToolTip="Redirect" />
                        </ItemTemplate>
                    </asp:TemplateField>
                </Columns>
            </asp:GridView>




//My Code Behind:

 protected void ScriptManager1_Navigate(object sender, HistoryEventArgs e) // Event handler for restoring state
        {
          Session["Id"] = e.State["value"];
        }

protected void grid_RowCommand(object sender, GridViewCommandEventArgs e)
        {
            string id= Convert.ToString(e.CommandArgument);
            if (e.CommandName == "redirect")
            {

                ScriptManager.GetCurrent(Page).AddHistoryPoint("value", idInThePage);
                Session["TipoDocumento"] = id;
                Response.Redirect("RedirectPage.aspx");
            }
        }

Hi

You can try avoiding to go back from IE using the below code.

javascript: window.history.forward(1);

Refer the below link for more details using this with different browsers.

http://go4answers.webhost4life.com/Example/windowhistoryforward1-historygo1-159725.aspx

Hope this helps.

 

On your ScriptManager, you need to set EnableHistory="true". Then, on the buttons that change from page1 to page 2 (to print page #3), you have to invoke ScriptManager.GetCurrent(Page).AddHistoryPoint("KeyName", value);

This saves the back button history state.

Now you have to override the OnNavigate event of the ScriptManager (or ScriptManagerProxy if your ScriptManager is in a MasterPage). When navigating, you have to restore the user’s previous state manually.

The default behavior of the back button is what you are seeing — it goes to the previous URL loaded in the browser. When you are using UpdatePanels, this URL doesn’t change.

There are a few tutorials about this, here is one:

http://geekswithblogs.net/ranganh/archive/2008/11/17/enabling-the-browserrsquos-back-button-for-grid-view-asp.net-ajax.aspx

You can also google against ScriptManager, EnableHistory, AddHistoryPoint, and OnNavigate.

since the SP1 update for .NET 3.5 you have the History control for AJAX. This was specifically crafted for this task:Introduction to ASP.NET
AJAX History
.

http://quickstarts.asp.net/Futures/ajax/doc/history.aspx

http://weblogs.asp.net/brijmohan/archive/2008/09/11/using-asp-net-3-5-history-control-with-asp-net-2-0.aspx

http://www.nikhilk.net/BackButtonSupport.aspx

Hi,

thanks for your reply. I saw your anwser in other post. If you see the code I did everything what you said. But its not working. The onNavigate event never fires.

I did one solution but wasn’t perfect. I cleared the cache and kept every thing like i showed in my code above. Now everytime I click at the back button, the Page Load event is fired and It checks if the Session["Id"] is the same. Its not the same so it
redirects for the Initial Page.

I did my reaserch, read every post you gave. But it didn’t worked.  If need any more code please let me know.

 

Thanks

I do not want to block the back button event, Its said to be bad practice.

 

But thanks for your reply.

[RESOLVED]Update Panel / Script Manager getting overwhelmed.

The short story, is when I have a bunch of databound controls(15+) all inside of an update panel it starts flaking out and not detecting changes. I have also had strange issues with radio buttons coming unselected after postback.

Here is the stackoverflow post about that.

http://stackoverflow.com/questions/18195063/how-to-get-radio-buttons-list-items-to-stay-selected-during-postback

For example. I had a lisbox whose selected indices were to populate a dropdownlist. On a minimal example, this worked fine. On  my  webforms page with 600 line of asp.net code and 2k of codebehind it did not. The minimal example was a direct copy and paste.

Worse yet still I had found a way to completely sever the connection between the webpage and the codebehind. (all events stopped firing in debug). Here is a video of what I am talking about.

https://docs.google.com/file/d/0B12ZVcp_VQ_xR3c0cU1LaXd5Vkk/edit?usp=sharing

Here is the StackOverflowPost that is related to it.

http://stackoverflow.com/questions/18278169/how-to-dynamically-copy-selected-listitems-from-a-listbox-to-a-dropdownlist-and

I  also had a similar experience in the past. I had posted my code for microsoft but they asked instead for a minimal example. Overwhelming update panels and the scriptmanager is impossible in minimal example according to all of my tests. To replicate this
you need 15+ databound controls with several of them with SelectedIndexChanged events that populate or change the visibility of other controls such as dynamially removing rows from a databound gridviews.  Or copying only the selected indicies from one listbox
to a dropdownlist.

This example works ( the minimal example 2 databound controls, 2 update panels 3 methods)

aspx

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="test.aspx.cs" Inherits="AdminSite.Catalogdata.test" %>
<!DOCTYPE html>
<html>
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>

<asp:ScriptManager ID="ScriptManagerProxy1" runat="server" >
<Scripts>
<asp:ScriptReference Path="~/Scripts/MassUpdate.js" />
</Scripts>
</asp:ScriptManager>
<div>
<h3 style="color:Red; padding-left:5px;">
WARNING - This page can push large amounts of data into the database. Use care when using it!

</h3>
</div>
<asp:UpdatePanel ID="OverallUpdater" UpdateMode="Conditional" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>
<span id="Span1" runat="server" style="padding:8px; position:relative;">

<asp:Listbox AutoPostback="True" ID="GroupList" runat="server" Width="166px"
SelectionMode="Multiple" OnSelectedIndexChanged="GroupList_SelectedIndexChanged"
DataSourceID="GroupSource" DataTextField="GroupName" DataValueField="GroupID">
</asp:Listbox>
<asp:SqlDataSource ID="GroupSource" runat="server"
ConnectionString="<%$ ConnectionStrings:ACESConnectionString %>"
SelectCommand="SELECT [GroupName], [GroupID] FROM [PrimaryGroup] ORDER BY [GroupName]"></asp:SqlDataSource>
</span>

<asp:UpdatePanel ID="UpdatePanel1" UpdateMode="Conditional" runat="server" ChildrenAsTriggers="true">
<ContentTemplate>

<asp:DropDownList runat="server" Width="150px" ID="grouplist2" DataTextField="Group" DataValueField="GroupID">

</asp:DropDownList>
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>

</div>
</form>
</body>
</html>

C# codebehind

using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace AdminSite.Catalogdata
{
    public partial class test : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }
        protected void GroupList_SelectedIndexChanged(object sender, EventArgs e)
        { updategroupEntry(); }

        protected void updategroupEntry()
        {
            string query = "";
            query += "SELECT    [GroupName] as [Group] ,  [GroupID] FROM [ACES].[dbo].[PrimaryGroup] Where ([GroupName] ='')";
            string[] y = query.Split(')');
            query = y[0];

            foreach (ListItem li in GroupList.Items)
            {
                if (li.Selected)
                {
                    query += " OR  [GroupName] = '" + li.Text + "' ";

                }

            }
            query += " )";
            DataTable dt = getDataTable(query);
            grouplist2.DataSource = dt;
            grouplist2.DataBind();

        }
        private DataTable getDataTable(string query)
        {

            SqlConnection con = new SqlConnection();
            con.ConnectionString = ConfigurationManager.ConnectionStrings["ACESConnectionString"].ConnectionString;
            con.Open();
            SqlCommand Subcmd = new SqlCommand(query);
            Subcmd.Connection = con;
            SqlDataAdapter da = new SqlDataAdapter(Subcmd);
            DataTable dt = new DataTable();
            da.Fill(dt);
            con.Close();
            con.Dispose();
            return dt;

        }
    }
}

This code was copied from the small file but originated from a larger file. It works
only in the smaller example but not the larger one, despite being self-contained.

Dear microsoft, I am loosing my patience with this issue. I have provided enough documentation for you to be able to replicate it. (See earlier comment).

That all being said. If you happen to see some solution to one of my stackoverflow posts, don’t hesistate to post it.

In the mean time, If you guys have a whole and complete post/tutorial  on How to use jQuery ajax with webservices so I can try to find a workaround that would be great.

hi zadkielmodeler ,

From what I understand  that you had strange issues with radio buttons coming unselected after postback with Update Panel and Script Manager and all inside of an update panel it starts flaking out and not detecting changes.

1. there is  a whole and complete tutorial  on How to use jQuery ajax with webservices:

http://www.asp.net/ajax/documentation/live/tutorials/UpdatePanelWithWebService.aspx

2. radio buttons coming unselected after postback:

http://stackoverflow.com/questions/843479/radiobuttonlist-is-unchecked-after-postback

http://forums.asp.net/t/1606830.aspx

i hope it helps you.

That is quite helpful thank you.

Well the radio button list coming unselected was not helpful because, no where in my code am I doing anything to unselect them. No jquery, no C# nothing.

But, thank you for the tutorial on webservices.

Just an odd item, but your example has an update panel within an update panel, your final page doesn’t have nested updatepanels does it?

It does have them.

When you say final page. I assume you are talking about something that I have never directly posted about. But I do have a big webpage in which I have some nested update panels. My example code is literally copied and pasted from my ‘final page’.

If you want I can give you the source code. But all the string building and database connection stuff would have to be replaced with your own, because I cannot give a copy of the database.

hi firend,

 i dont see your Update Panel  in  final page. I assume that your  issue is unselect them of dropdownlist  with  No jquery, no C# nothing .

i sugesst you to add empty ListItem and Selected.

using the HTML source:

<asp:DropDownList ID="DDL" runat="server" >
<asp:ListItem Selected="True"></asp:ListItem>
</asp:DropDownList>

if it not works, please post  your  the source code and  give me email.

Microsoft JScript runtime error: 'WebService' is undefined ??

Hey all, ive been using CTP Atlas for a while, and im tying to upgrade some of my code to beta 1..

but im getting: Microsoft JScript runtime error: ‘WebService’ is undefined

New project > Ajax Enabled Website

WebService.asmx.js
function test()
{
    WebService.HelloWorld();
}

WebService.asmx
[WebMethod]
public void HelloWorld()
{
    string test=  "Hello World";  //added a breakpoint here to catch the call
}

Default.aspx
<asp:ScriptManager ID="ScriptManager1" runat="server">
    <Services>
       <asp:ServiceReference Path="WebService.asmx" />
    </Services>
    <Scripts>
 <asp:ScriptReference Path="WebService.asmx.js" />
    </Scripts>
</asp:ScriptManager>
<div>
     <button type=button onclick="test();" >hahaha</button>
</div>

 

thats the basics ive done, now it should work….. but it doesnt :-(

Any idea waht im doing wrong?? Cheers guys!

 

 

I had the same issue, but found that the WebService.asmx class required a new attribute.  Once I added it, all worked:

[Microsoft.Web.Script.Services.ScriptService()]
public class WebService : System.Web.Services.WebService
{
 [WebMethod]
 public void HelloWorld()
 {
     string test=  "Hello World";  //added a breakpoint here to catch the call
 }
}

Hope this helps. 

 

steven 

 

Folks,

I am having the same problem. Adding the scriptservice attribute does not help.

 //Web Service

Imports System.Web

Imports System.Web.Services

Imports System.Web.Services.Protocols

Imports Microsoft.Web.Script.Services

 

<WebService(Namespace:="http://tempuri.org/")> _

<ScriptService()> _

Public Class CarService

Inherits System.Web.Services.WebService

<WebMethod()> _

Public Function getcarvalue(ByVal strCarMake
As String,
ByVal strCarModel
As String,
ByVal strCaryear
As String)
As Integer

……..

End Function

End Class

//Client Code

<script language="javascript"
type="text/javascript">

// <!CDATA[

function Button1_onclick() {

requestValue = CarService.getcarvalue(

form1.txtMake.value,

form1.txtModel.value,

form1.txtYear.value,

OnComplete,

OnTimeOut);

return false;

}

function OnComplete(result)

{

alert("Car is worth: $" + result);

}

function OnTimeOut(result)

{

alert("Timeout: " + result);

}

 

// ]]>

</script>

</head>

<body>

<form
id="form1"
runat="server">

<div>

 

<asp:ScriptManager
ID="ScriptManager1"
runat="server">

<Services>

<asp:ServiceReference
Path="CarService.asmx"/>

</Services>

</asp:ScriptManager>

 

Make: &nbsp;

<input
id="txtMake"
type="text"
/>

<br
/>

Model:&nbsp;

<input
id="txtModel"
type="text"
/><br
/>

Year: &nbsp;&nbsp;

<input
id="txtYear"
type="text"
/>

<br
/>

<input
id="Button1"
type="button"
value="Get Value"
onclick="return Button1_onclick()"
/></div>

</form>

</body>

</html>

 

 

I’m also having the same problem.  It would seem that someone from Microsoft would explain the bugs they create.  If anyone could figure out how to fix this problem, please let us know.

 Thanks,

Michael.

Hi kali.mist,

I tested your code against Beta 2 and it worked just fine.

Maíra

Thanks Maira,

I rebuilt everything from scratch and it worked!! Ive compared the two web sites but could not find the problem that caused the first to fail.

Cheers

Mick

 

In your case Kryptonic, the first thing to do would be to add the [Microsoft.Web.Script.Services.ScriptService()] to the web service.

Another thing that I noticed is that your javascript function doesn’t have a callback function. You need to add something like this:
function test() {
WebService.HelloWorld(OnRequestComplete);
}

// Event handler that processes the
// Web service return value.
function OnRequestComplete(result)
{
alert(result);
}

Make sure that you rebuild your solution, in order to update the generated proxy file for your web service.
You can check the proxy file, typing /js after your service address (e.g. http://yourapppath/yourservicename.asmx/js)

I also would use another name for the web service just to avoid collision with the WebService attribute. 

And the last thing (I guess)… I would change the way you include your js file. The ScriptReference control is meant to be used differently.
So I would place the script code inside the page or would add trough a 
<
script type="text/javascript"
src="WebService.js"
/>

Hope that helps,

Maíra

Hi

 I came across this page lookig for the web service undefined error problem.  I eventually found the problem which was namespace related.  Ive detailed it in my blog:

http://omensblog.blogspot.com/2007/07/aspnet-ajax-web-service-calls-from.html

cheers

Damian

 

The problem lies when you are using a web application project. Since web application projects use namespaces you need to add it before your call to the service. Also I needed to add
using System.Web.Script.Services; and [ScriptService] to my asmx code behind. Below I will give an example of how to get this working.

Create your webservice. I added mine in a sub directory of my site named Services. So when looking into the code behind of the webservice you will see something like:
namespace MyNamespace.Services you want to remember this. Next thing is to add:
using System.Web.Script.Services; with the rest of the includes and also add the line:
[ScriptService] just before the public class MyService : System.Web.Services.WebService

Next is to go to the aspx page and create the proxy.

  

<asp:scriptmanagerproxy id="ScriptManagerProxy" runat="server">
	<services>
		<asp:servicereference path="~/Services/MyService.asmx"></asp:servicereference>
	</services>
</asp:scriptmanagerproxy>
 
Next comes the javascript

<div class=”codecolorer-container javascript”><div class=”codecolorer” style=”font-family: monospace;”><script language=”javascript” type=”text/javascript”></div><div class=”codecolorer” style=”font-family: monospace;”> </div><div class=”codecolorer” style=”font-family: monospace;”>    function ButtonClick()
        { MyNamespace.Services.MyService.MyFunction(OnComplete) }
</div><div class=”codecolorer” style=”font-family: monospace;”> </div><div class=”codecolorer” style=”font-family: monospace;”>    function OnComplete(results)
        { alert (results) }
</div><div class=”codecolorer” style=”font-family: monospace;”> </div><div class=”codecolorer” style=”font-family: monospace;”></script> </div></div>

Notice the “MyNamespace.Services.” before the name of the webservice. This is important to add when using a web application project, it is not need when making a regular
web site because a web site does not use namespaces. So there you go, you should now be able to get things up and running.

 

Hi Lankern,

I am also using a Web Application prject and I have added a namespace to the .asmx class. However my code is calling the js page but gets an error on the line where i make the call to the WebService. I have been circling this issue for 2 days, any help is
greatly appreciated.

<asp:ScriptManager ID="ScriptManager1" runat="server">
        <Services>
            <asp:ServiceReference Path="WebService.asmx" />
        </Services>
        <Scripts>
            <asp:ScriptReference Path="WebService.js" />
        </Scripts>
    </asp:ScriptManager>

 

// JScript File
function HelloWorld(url) {
   Namespace.Services.WebService.HelloWorld(url,OnSucceeded);
}
function OnSucceeded(result, userContext) {
   alert(result);
}


if (typeof(Sys) !== "undefined") Sys.Application.notifyScriptLoaded();

 

Hi andyaiyer,

What is the error message you’re getting?

Do you have the
ScriptService
attribute applied to your Web service class?

Regards,

Maíra

Maira,

 Thank you for responding to my issue. Please allow me to explain in more detail what I am trying to do. I have 2 Web Application projects, they are mutually remote to each other. Let us call them ServerProjA and ClientProjB.  I am trying to call a web service
which is on the remote Server (ServerProjA) using AJAX ASP.Net on the client project (ClientProjB). Since ASP.Net does not allow you to call a Remote Web Service using AJAS ASP.Net… I have added a Web Service (ClientWS) to my client project (which is a wrapper
to my remote Web Service) .

I was getting an error when i was trying to access the Web Service (ClientWS) from within my JScript on the Client Javascript page.

However now upon further debugging….when I tried to directly access the Client Web service
http://localhost/ClientProjB/ClientWS.asmx (for example) and invoke a Web Method. Please note that this web service will dynamically call the Web Service on ServerProjA, I am passing the web service URL
dynamically (http://localhost/ServerProjB/ServerWS.asmx ) I get the following error

System.NotSupportedException: The URI prefix is not recognized.
   at System.Net.WebRequest.Create(Uri requestUri, Boolean useUriBase)
   at System.Net.WebRequest.Create(Uri requestUri)
   at System.Web.Services.Protocols.WebClientProtocol.GetWebRequest(Uri uri)
   at System.Web.Services.Protocols.HttpWebClientProtocol.GetWebRequest(Uri uri)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.GetWebRequest(Uri uri)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at FG9State.RegionalWSProxies.Mandates.RegisterMandates.HelloWorld() in C:WorkFitnessGramHK CoreHK Core 1.0FG9StateBOLRegisterMandates.vb:line 63
   at FG9State.StateMandates.HelloWorld(String WebServiceURL) in C:WorkFitnessGramHK CoreHK Core 1.0FG9StateStateMandates.asmx.vb:line 18
The following is the  Web Service (ClientWS) in my client project (which is a wrapper to my remote Web Service) .
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Web.Script.Services


<WebService(Namespace:="Microsoft.Samples.XmlMessaging.WebServices")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1, EmitConformanceClaims:=True)> _
<ScriptService()> _
Public Class StateWrapper
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function HelloWorld(ByVal WebServiceURL As String) As String
        Dim strResult As String
        Dim WS As New NameSpace.Services.WebService() ' Calling the remote Web Service here
        WS.Url = WebServiceURL			'Pasing the URL of the location of the web service.
        strResult = WS.HelloWorld()
        Return strResult
    End Function
End Class

  My ServerWebService tests okay when i invoke the Service directly in a Browser …and is a simple implementation.

WebService(Namespace:="Microsoft.Samples.XmlMessaging.WebServices")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1, EmitConformanceClaims:=True)> _
<ScriptService()> _
Public Class WebService
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function HelloWorld() As String
        Return
"Hello World"
    End Function
End Class

 

I dont understand why i cannot get the 2 web services to talk to each other? If i can achieve this first then i can call my first web service via AJAX. If you have questions please feel free to indulge me, I am tried a lot of different things from changing
namespaces to client side debugging etc. One more note is that I am using Web Application Projects and not Web site project.

 your help is very appreciated.

Apparently the problem you’re having is not in Ajax, but in the communication between the two Web services.
I would do a couple of things to isolate the problems:
- I would make the wrapper just return a string and nothing else, just to make sure that the Ajax part is working in your Web application;
- I would create a test page and call the web service from the remote server in the traditional way to make sure that your proxy configuration is OK;

Hope this helps,

Maíra

Maira,

Thank you for your help 

Please consider this issue closed. I have documented the problem, steps and solution here for whoever is reviewing my thread. Please remember that i was using Web Application Project in my solution (not Web site).

1. I had to do a clean and rebuild after which my Web Service from ProjA was able to communicate with web service in ProjB.

2. I did not find a successful documented way to do consume a Web Service hosted on a remote domain via AJAX. The only article I found was to create a wrapper Web Service in your project which makes calls to the Remote WS and then you can AJAX call the web
service wrapper in your project using Script Manager , Services, Scripts etc. However i kept getting the ‘Webservice is undefined’ JScript error. I still wish if someone has an implementation or solution that they can share,

3. What i ended up doing is to make the web service call as a HTTP request to the remote domain directly from another form. The flow is as follows Button Click-> Java Script–> Call a Form1.aspx, and in Form1 codebehind make the call to Remote Webservice
and return the data back.

 

I have only been able to call Web Services from JS when the Project type was a "Web Application".  When trying this in a "Web Site" solution in Visual Studio, it never works.

 Can anyone confirm that the project needs to be a "Web Application" vs adding a web service to your web site and trying this?

 Edit : Ignore my post.  I figured out the Namespace issue afterward.

I’m also getting this issue but even when I add the namespace it doesn’t fix it. I have a web application with the namespace MyWebApp and the web service is in this project. When I just call MyWebService.ReturnResults…. I get a message saying ‘MyWebService
is undefined’. When I prefix with the namespace I then get a message saying ‘MyWebApp is undefined. The call to the web service is actually made from an ASP.Net AJAX control which is in another project with a different namespace. Could this be causing my issue?
My web service starts as below… 

namespace MyWebApp
{
    [WebService(Namespace = "http://tempuri.org/")]
    [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
    [ToolboxItem(false)]
    [System.Web.Script.Services.ScriptService]
    

    public class MyWebService : System.Web.Services.WebService
    {
      [WebMethod]
      public DataTable ReturnResults(string searchParametersJSONstring)
      {
        ....
      }
    }
}
Thanks

hi All,

 iam using java script  to Test  method execution time. the method  written in webservice.its running perfectly but iam getting this error message "Microsoft JScript runtime error: ‘debug’ is undefined".

can  anbody help me.

Default.aspx

function TestTimeout()

{

 

debug.trace("–Start–");TestService.set_defaultFailedCallback(
function(result, userContext, methodName)

{

var timedOut = result.get_timedOut();

if( timedOut )

debug.trace( "Timedout: " + methodName );

else

debug.trace( "Error: " + methodName );

});

TestService.set_defaultSucceededCallback( function(result)

{

debug.trace( result );

});

 

TestService.set_timeout(5000);

TestService.HelloWorld("Call 1");

TestService.Timeout("Call 2");

TestService.Timeout("Call 3");

TestService.HelloWorld("Call 4");

TestService.HelloWorld("Call 5");TestService.HelloWorld(null);

 

}

 

Hi All,

I also had the same problem (Microsoft JScript runtime error: ‘WebService’ is undefined). It’s all about a Namespace Issue :). But now the problem is web service doesn’t return the value i wand when it is called within the javascript. Instead it’s saying
"Undefined"

[WebMethod()]

[ScriptMethod()]

public
string HelloWorld()

{

return
"Hello World";

}

Ok I have been racking my brain out on this searching loads of pages for ours trying to find a solution. I have finally found what fixed it for me, however it seems there are loads of solutions scattered all over the internet that have worked for others
so no idea if this is the one.

I found that I needed ot create functions to deal with the respond of my web service in JavaScript, calling the web service name and passing it directly into a function is not enough, you need to specify the name of the functions in the parameters when calling
a WS in JavaScript like this:

<script type="text/javascript">

    NameSpaceName.WebServiceName.HelloWorld(OnSuccess, OnFail);


    function OnSuccess(asd) {
        alert("Success: " + asd);
    }

    function OnFail(asd) {
        alert("Fail: " + asd);
    }

</script>

If your WebService accepts a parameter it will look like this:

<script type="text/javascript">

    var paramter1 = "The parameter contents"
    NameSpaceName.WebServiceName.HelloWorld(parameter1, OnSuccess, OnFail);


    function OnSuccess(asd) {
        alert("Success: " + asd);
    }

    function OnFail(asd) {
        alert("Fail: " + asd);
    }

</script>

I am assuming that you just add as many parameters as you need… I havn’t tested it with more than one though.

 

Hope this helps save some people some time! It certainly took me a while to figure it out.

 

[RESOLVED]How to use ScriptManager in master page when content pages already have ScriptManager?

The content pages in my project have ScriptManager control but the Master Page does not have. I now want to use UpdatePanel in the master page but it is not permitting to put another ScriptManager.

I cannot change to ScriptManagerProxy in content pages as the change needs to be replicated to around fifty pages.

Is there any way to use UpdatePanel in Master Page by either sharing content page’s ScriptManager or something else?

From MSDN:

"Any ASP.NET page that includes an UpdatePanel control also requires a ScriptManager control. To use UpdatePanel controls with master pages, you can put a ScriptManager control on the master page. In this scenario, the master page provides a ScriptManager control
for every content page. If you do not want partial-page updates enabled for individual content pages, you can disable partial-page updates for those pages.

Alternatively, you can put the ScriptManager control on each content page. You might do this if only some of the content pages will contain UpdatePanel controls."

…so you can’t have the ScriptManager on both the content an master page.

Place scriptmanager in master page, remove scriptmanager in all pages.

Any ASP.NET page that includes an UpdatePanel control also requires a
ScriptManager control. To use
UpdatePanel controls with master pages, you can put a
ScriptManager control on the master page. In this scenario, the master page provides a
ScriptManager control for every content page. If you do not want partial-page updates enabled for individual content pages, you can disable partial-page
updates for those pages.

http://msdn.microsoft.com/en-us/library/bb398864(v=vs.100).aspx

<div class="subsection">

A Web page can contain only one ScriptManager control, either directly on the page or indirectly inside a nested or parent component. The
ScriptManagerProxy control lets you add scripts and services to content pages and to user controls if the master page or host page already contains a
ScriptManager control.

When you use the ScriptManagerProxy control, you can add to the script and service collections defined by the
ScriptManager control. If you do not want to include specific scripts and services on every page that includes a particular
ScriptManager control, you can remove them from the
ScriptManager control. You can then add them to individual pages by using the
ScriptManagerProxy control instead.

</div>

Hii,

Put your script manager in master page.

Remove from all other webforms.

in one page only script manger is there.not more then once.

Using script manager in webforms is not good practice.

Put it in master page so you don’t have put again.

[RESOLVED]question on ScriptManager.RegisterStartupScript

Hello Everyone,

Actually this topic, together with the updatepanel, has confused me already for some time.

Inside a content page, I have some javascript files, an ASP.net Panel, inside which there is a multiview, inside which there is a gridview, each encapsulated with an updatepanel, something like the following:

<asp:Content ID="contentMain" runat="server" contentplaceholderid="contentMainMaster">

    <asp:ScriptManagerProxy ID="ScriptManagerProxy1" runat="server">
        <Scripts>
            <asp:ScriptReference Path="../JavaScript/JSFile.js" /> <%-- where the JS function stays --%>
        </Scripts>
    </asp:ScriptManagerProxy>

    <asp:UpdatePanel ID="UpdatePanelMain" runat="server"> <%-- the 1st updatepanel --%>
    <ContentTemplate>
        <asp:Panel ID="panMain" runat="server" >
            <asp:UpdatePanel ID="UpdatePanelMultiView" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="False"> <%-- the 2nd updatepanel --%>
            <ContentTemplate>
                <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0" >
                    <asp:View ID="View1" runat="server">
                        <asp:Panel ID="panSub1" runat="server>
                            <asp:UpdatePanel ID="UpdatePanelGrid1" runat="server" UpdateMode="Conditional">
                            <ContentTemplate>
                                <asp:GridView ID="Grid1" runat="server">
                                <%-- some contents --%>
                                OnDataBound="onGrid1DataBound" <%-- I use registerstartupscript inside this function --%>
                                </asp:GridView>
                            </ContentTemplate>
                            </asp:UpdatePanel>
                        </asp:Panel>
                    </asp:View>
                </asp:MultiView>
            </ContentTemplate>
            </asp:UpdatePanel>
        </asp:Panel>
    </ContentTemplate>
    </asp:UpdatePanel>

Whenever the databound of gridview takes place, I want to execute a javascript function inside the file already registered with ScriptReference. Like this (notice that I use UpdatePanel control as the “control” parameter):

protected void onGrid1DataBound(object sender, EventArgs e)
{
    ScriptManager.RegisterStartupScript(UpdatePanelGrid1, UpdatePanelGrid1.GetType(), "Grid1Bound", "onGrid1Active()", true);
}

Now the things that I don’t understand:

I use a timer control to update the gridview (bind) every 2seconds. With the code above, with firebug, I see that the "onGrid1Active" javascript function indeed gets called on every databound event.

However if I remove the 1ST updatepanel (ID ==UpdatePanelMain), the function gets called only once, 

I could not figure out how the presence of this 1st updatepanel could influnce the gridview, which is inside the 3rd updatepanel ?

I would appreciate any comment.

Edit:

If I remove the updatepanel with ID==UpdatePanelMain, but in the timer function, after making "bind" to the gridview, If I call manually "UpdatePanelGrid1.update()", the javascript function gets called correctly.

You have specified

ChildrenAsTriggers="False"
for the second update panel which might be the culprit. ChildrenAsTriggers indicates whether postbacks from immediate child controls of an UpdatePanel control update the panel’s content.

Because you set it to false no child elements inside the update panel will refresh the content unless you give the triggers to the updatepanel.

I also do not see any triggers for the second update panel . So obviously the content won’t refresh.

The 1st UppdatePanel comes to your rescue here as any control inside it will update the page.

.Update() method nothing but , you are explicity updating the updatePanel. so this works.

Thank you very much! I made a couple of test. I think that now I understand better the usage of the updatepanel.

[RESOLVED]Panel not appear in Web Developer 2008 Express

Hi,

I added a panel with ModalPopupExtender in a web form. Opening this form at Visual Web Developer 2008 Express, only seen ModalPopupExtender, not seen the panel. At Soure, all panel code exists. Why not shown?

<input id="gwProxy" type="hidden"><input onclick="jsCall();" id="jsProxy" type="hidden">

<div id="refHTML"></div>

Please post your markup. 

I created this web project firstly as a web site project in VS 2005. And then I want to make this project as a asp web application. So I created new asp web application, added some web forms and converted all these forms to web application by using ‘convert
to web application’. Here I added httphandler at web.config because ajax control is not apeared at run time.

Now I use this web application with VS 2008. In VS 2008, panel are not appeared.

So I make a new VS 2008 asp web application project and add ajax control to web content form. This error message is appeared ‘The operation could not be completed‘. Help me!Undecided

soclose

Here I added httphandler at web.config because ajax control is not apeared at run time.

 

There is no reason to add an HttpHandler to your web.config file, because of AJAX. If you have installed the AJAX Control Toolkit, or the new AJAX Library on your machine, you’ll be fine. You need to register the controls, which can be done in the page or
in the web.config file, with the simplest being that you drag a control from the Toolbox onto a Web Form.

Please show us the markup for the Web Form, on which you have the AJAX control, if possible.

This is my testing web form code in my web project. Source code is below

<%@ Page Language="C#" MasterPageFile="~/SFAMasterPage.master" AutoEventWireup="true" Inherits="Default2" Title="Untitled Page" Codebehind="Default2.aspx.cs" %>


<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>


<%@ Register Assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
    Namespace="System.Web.UI" TagPrefix="asp" %>


<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
    

    <asp:LinkButton ID="LinkButton1" runat="server">LinkButton</asp:LinkButton> 
    <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="TextBox1">
    </cc1:CalendarExtender>
     
    <asp:Panel ID="Panel1" runat="server" CssClass="modalBox" style =" display :none;">
        <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label></asp:Panel>
    <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1">
        <Columns>
            <asp:BoundField DataField="sptname" HeaderText="sptname" SortExpression="sptname" />
        </Columns>
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:MSFAConnectionString %>"
        SelectCommand="SELECT * FROM testspt;" ProviderName="<%$ ConnectionStrings:MSFAConnectionString.ProviderName %>">
    </asp:SqlDataSource>
    <cc1:modalpopupextender id="ModalPopupExtender1" runat="server" targetcontrolid="LinkButton1" PopupControlID="Panel1" BackgroundCssClass = "modalBackground"></cc1:modalpopupextender>
     
    <asp:CheckBoxList ID="CheckBoxList1" runat="server" Height="1px" Width="234px">
        <asp:ListItem>CCTV - S$988 Packages</asp:ListItem>
        <asp:ListItem>Intrusion Alarm - S$588 Package</asp:ListItem>
        <asp:ListItem>Multiple Security Solution</asp:ListItem>
        <asp:ListItem>CCTV - Wireless Solutions</asp:ListItem>
    </asp:CheckBoxList>
    <asp:DropDownList ID="DropDownList1" runat="server">
    </asp:DropDownList> 
    <asp:ListBox ID="ListBox1" runat="server" Height="53px" SelectionMode="Multiple">
        <asp:ListItem>CCTV - S$988 Packages</asp:ListItem>
        <asp:ListItem>CCTV - S$988 Upsell Packages</asp:ListItem>
        <asp:ListItem>Intrusion Alarm - S$588 Package</asp:ListItem>
        <asp:ListItem>Multiple Security Solution</asp:ListItem>
    </asp:ListBox>
    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
    <asp:TextBox ID="TextBox2" runat="server" TextMode="MultiLine"></asp:TextBox>
</asp:Content>

I have already installed ASPAJAXExtSetup.msi on window Vista. Should I need to install this
ASP.NET Ajax Library 0911 Beta -
http://ajax.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=35895#ReleaseFiles – for VWD 2008 Express?

The style for your Panel control is set like this: style =" display :none;", which means it is not displayed. 

integrasol

The style for your Panel control is set like this: style =" display :none;", which means it is not displayed. 

Surprised this is at design time, not at run time. So the panel should display, is it?

<input id="gwProxy" type="hidden"><input onclick="jsCall();" id="jsProxy" type="hidden">

<div id="refHTML"></div>

Well, try and remove it. ;-)

Now It works. Thanks.Smile

I have two more errors -

  1. I can’t drop any ajax control to this VWD 2008 Express
  2. For script manager, I get this error message "Error Creating Control – ScriptManager1 The server tag ‘asp:ScriptManager’ is ambiguous. Please modify the associated registration that is causing ambiguity and pick a new tag prefix." 

For the 2nd error, I also add scriptManager at MasterPage. That’s why? I add script manager in this test web form before. I just only removed this control. I not know how to modify the associated registration.

<input id="gwProxy" type="hidden"><input onclick="jsCall();" id="jsProxy" type="hidden">

<div id="refHTML"></div>

If you have a ScriptManager control in your master page, you need to a
ScriptManagerProxy control to your content pages. Try adding the
ScriptManagerProxy control to your content page first, and then do a drag and drop.

I add ScriptManagerProxy in web content form but can’t drag and drop Ajax Control to this form.

integrasol

I have already installed ASPAJAXExtSetup.msi on window Vista. Should I need to install this
ASP.NET Ajax Library 0911 Beta -
http://ajax.codeplex.com/Release/ProjectReleases.aspx?ReleaseId=35895#ReleaseFiles – for VWD 2008 Express?

Do I need to install this Ajax Library 0911 Beta?

See http://forums.asp.net/t/1139967.aspx?PageIndex=1

To install new version, you need remove old one http://www.asp.net/learn/Ajax-Control-Toolkit/tutorial-47-cs.aspx

Thanks Sun Light. Your links are so useful for me.

In my VWD 2008 project, I remove old Ajax dll reference and add new ajax reference – AspNetAjaxLibraryBeta0911. And then at my toolbox, I remove old ajax controls and add new ajax ones. Now I could drag and drop any ajax control to my web form but only in
source code.