Solved

Pop-up in user control functioning in one page but not another.

Posted on 2008-06-16
12
300 Views
Last Modified: 2011-10-19
I have a user control with the attached javascript to generate a pop-up window.  When the user control is embedded in one page it works perfectly.  However, embedded in another page, the window never pops up.  I notice that generated link that initiates the popup is different in each of the pages.  On the page where it works it looks like this:  

javascript:__doPostBack('ctl00$ContentPlaceHolder1$ContactLogDetail_1$ContactLogDetailsView$AssignedToIDTxtBox$AssignedToLinkButton','')

On the page where it does NOT work, it looks like this:

javascript:WebForm_DoPostBackWithOptions(new WebForm_PostBackOptions("ctl00$ContentPlaceHolder1$ContactLogDetail_1$ContactLogDetailsView$AssignedToIDTxtBox$AssignedToLinkButton", "", true, "", "", false, true))

What would be causing this difference?  Is this what is causing the window to not pop up in the second scenario?

I'm on a tight deadline.  Any assistance would be greatly appreciated.
Ann
<%@ Control Language="C#" AutoEventWireup="true"  CodeFile="FindEmployeeScript.ascx.cs" Inherits="UserControls_FindEmployee"  %>

<script type="text/javascript">

function RenderSearchScreenPopUp(elementID)

{                          

    var ParmA; 

    var SearchResultField = "<%=SearchFldName%>";

    var MyArgs = new Array(ParmA); 

    var WinSettings = "center:yes;resizable:no;dialogHeight:600px;dialogWidth:100px;toolbars:yes";  

  // var randomNum = Math.floor(Math.random() * 1000001);

   //var altLink = "?RandDom=" + randomNum;

  var altLink = "?";

    

    var MyArgs = window.showModalDialog("/AimSystemIntranet/UserControls/PopUpEmployeePicker.aspx" + altLink, MyArgs, WinSettings);   

    if (MyArgs == null)

    {       

      // do nothing

    }

    else

    {                                                                              

        alert(MyArgs[0]);

        document.getElementById(elementID).value = MyArgs[0];

        //document.forms[0].namedItem("UserControlDateTxtFld").value = MyArgs[0];           

    }

    return false;

         

}
 
 
 

</script>
 

<table>

<tr>

<td>

<asp:TextBox runat="server" ID="UserControlAssignedToFld"></asp:TextBox>

 </td> 

 <td>

     <asp:LinkButton ID="AssignedToLinkButton" runat="server">Find</asp:LinkButton>

    </td>

 </tr>
 

</table>
 

<!--code behind-->
 

public partial class UserControls_FindEmployee : System.Web.UI.UserControl

{

    protected string SearchFldName = "";

    protected int instanceNumber = 1;

    private const int FirstInstance = 1;

    

    protected void Page_Load(object sender, EventArgs e)

    {

        string linkID = this.UserControlAssignedToFld.ClientID;

       

        AssignedToLinkButton.Attributes.Add("onclick", "return RenderSearchScreenPopUp('" + linkID + "');");

        

       

    }
 

    public string NonEnteredDefaultValue

    {

        get { return ""; }

    }
 

    public string SelectedEmployee

    {

        get

        {

                return UserControlAssignedToFld.Text;

           

        }

        set

        {

            this.UserControlAssignedToFld.Text = value.ToString();

        }

    }

Open in new window

0
Comment
Question by:annpearson
  • 7
  • 4
12 Comments
 
LVL 14

Expert Comment

by:ajitha75
Comment Utility
doPostbackwithOptions occurs if there are validator controls on the page.

The error is probably occuring because you are not having .axd mapping in IIS. Do as mentioned in the below website

http://www.developerdotstar.com/community/node/641

"Bring up IIS and right-click on your virtual directory. Select "Properties". On the Virtual Directory tab in the Application Settings section, click the "Configuration" button. This brings up the "Mappings" tab. Highlight the entry for ".axd" and click "Edit". Be sure that the lower left-hand checkbox for "Check that File Exists" is unchecked! If not, uncheck it and click "OK". The WebResource.axd references you see when doing "View Source" on a .NET webpage don't actually link to a physical file, so if this box is checked then the scripts don't get loaded correctly."
0
 

Author Comment

by:annpearson
Comment Utility
I followed your instructions.  The File Exists checkbox was already un-checked.  Any other ideas?
0
 

Author Comment

by:annpearson
Comment Utility
I also get a script error when clicking on the link to call the javascript.  The error is "Object expected".
Thanks again.
Ann
0
 

Author Comment

by:annpearson
Comment Utility
Hello, still looking for a solution for this.  When I remove the validator controls on the page it gets rid of the doPostBackWithOptions but the pop-ups still do not function, so it must not be related to that.  Any assistance would be greatly appreciated.
Thanks,
Ann
0
 
LVL 14

Expert Comment

by:ajitha75
Comment Utility
Can you send the source where the error is generated. Do a view source and send it. Also, the line number where the error "object expected" is coming. Also, if you can share the page where this control is added and it does not work, it will be helpful.
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 

Author Comment

by:annpearson
Comment Utility
Thank you.  I do have a little more information now.   If I remove the ruant="server" from the table that the user control is in, the pop-ups work. Also, if I leave the runat="server" and instead remove the line of code in my Page_Load event that sets the table's visibility to false, it also starts to work.  However; I need to be able to set the visibility to false when the page first opens and then set it to true when the user clicks on a link to view it.  I'm not sure I understand first of all why a runat="server" or an original visibility of false would cause this.  Do you have any insight about this?  If not, would there be another way to accomplish my goal?
Thanks again,
Ann
   

                 <table style="width: 675px" id="ContactLogViewTable" runat="server">

                          <tr>

                          <td>

                          <uc1:ContactLogDetail runat="server" ID="ContactLogDetail_1"      />

                          </td>

                          </tr>

                        </table> 
 

<!-- code behind line-->

 ContactLogViewTable.Visible = false;

Open in new window

0
 
LVL 14

Accepted Solution

by:
ajitha75 earned 500 total points
Comment Utility
The location of error i think is in different place. It is possible that after setting visible to false, some function is trying to access either ContactLogViewTable or ContactLogDetail_1 in javascript and hence getting the "Object Expected" error. Please go through your javascript functions again on this page and see if you missed anything
0
 

Author Comment

by:annpearson
Comment Utility
Thank you.  I am actually setting  the ContactLogViewTable visability back to true before this occurs.  In fact the link that I click is within the user control that is within this table.  It is when I click this link that the pop-up should generate, but instead I receive the error.  
Thanks again,
Ann
0
 

Author Comment

by:annpearson
Comment Utility
I have attached the view source, and the error is occuring on line number 847.
Thanks,
Aana
companyDetail-1-.txt
0
 
LVL 14

Assisted Solution

by:ajitha75
ajitha75 earned 500 total points
Comment Utility
And are you sure that when the link is clicked, that the page is able to identify the javascript method - RenderSearchScreenPopUp. because you are using ASP.NET Ajax,  it is possible, the javascript method is not available during Ajax call. put a alert inside the method and see if you are able to see that alert.
0
 

Author Comment

by:annpearson
Comment Utility
I think that was the issue.  I changed it to use a display:none instead of the visible=false.  Thank you!
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now