?
Solved

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

Posted on 2008-06-16
12
Medium Priority
?
333 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 4
12 Comments
 
LVL 14

Expert Comment

by:ajitha75
ID: 21799441
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
ID: 21799487
I followed your instructions.  The File Exists checkbox was already un-checked.  Any other ideas?
0
 

Author Comment

by:annpearson
ID: 21799507
I also get a script error when clicking on the link to call the javascript.  The error is "Object expected".
Thanks again.
Ann
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:annpearson
ID: 21806526
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
ID: 21809545
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
 

Author Comment

by:annpearson
ID: 21810226
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 1500 total points
ID: 21811925
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
ID: 21813425
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
ID: 21813491
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 1500 total points
ID: 21814891
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
ID: 21852681
I think that was the issue.  I changed it to use a display:none instead of the visible=false.  Thank you!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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…
Suggested Courses

762 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