.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Check Page Referer in Javascript?

Posted By:      Posted Date: August 29, 2010    Points: 0   Category :ASP.Net
Is there a way to execute a javascript function based on the page referer?So if the user comes from an internal page then doesnt execute but if it comes from an external page then it does?Thanks

View Complete Post

More Related Resource Links

Re-positioning an HTML container with javascript onresize with a Master page.


I have an HTML <div> container that I float to the right of a gridview.  When the browser window is maximized, it looks fine.  When minimized, the gridview positions below the floating container and most of the data is pushed off the bottom of the browser - you have to scroll down to see it.

If I position the floating container above the gridview it looks fine in a minimized window, but looks real bad when maximized.

What I want to do is use a javascript: onresize event to re-position the floating container up or down depending on the window.inner.width AND do it with a Master/Content page structure AND do it for only the one page where needed.

I can capture the onresize event and display the window dimensions but haven't figured-out how to do it with a Content page that still uses the Master page.  I think I'm having a very "thick" week...

- Tinker


Content page control passes as argument to javascript function


Here is the content page:


<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" AutoEventWireup="true" CodeFile="JavaDynamicCopyValue.aspx.cs" Inherits="JavaDynamicCopyValue" Title="Untitled Page" %>
<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
 <script type="text/javascript" >
 function copyValue(input, output )
   ouput.value = input.value;
   return true;
 <asp:TextBox ID="txt1" runat="server" onchange="copyValue(this,document.getElementById('<%=txt2.ClientID%>'))"></asp:TextBox>
    <br />
    <br />
    <asp:TextBox ID="txt2" runat="server"></asp:TextBox>


I got a javascript run time error says output is undefined. if I view source of the page, the txt1 markup became:

<input name="ctl00$ContentPlaceHol

ASP.NET Proxy Page - Used for Cross Domain Requests from AJAX and JavaScript

The article ASP.NET Proxy Page - Used for Cross Domain Requests from AJAX and JavaScript was added by Aamir Hasan on Thursday, August 19, 2010.

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn't allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull content

collapsiblepanelextender, master page and javascript

does anyone have any working code that uses javascript to open and close a cpe when the CPE is in a masterpage?  It seems like the javascript never is able to find the CPE when it is on a master page.  I have an DropDownList on the page and when certain items are selected, i want to collapse or expand when others are selected.  It seems to work fine on a regular page, but not when it is a page nested in a master page.  It is adding a suffix to the CPE and javascript is unable to find it.  any help would be much appreciated!<script type="text/javascript" language="javascript">        function ExpandCollapse() {            var e = document.getElementById("<%=DropDownList.ClientID%>")            var strUser = e.options[e.selectedIndex].value;            var collPanel = document.getElementById("<%=CPE.ClientID%>")            if (collPanel = null)                alert('No panel found');            if (strUser = "Collapse")    

Javascript: detect Page.IsValid and IsPostBack

In a client-side function that initializes a 3rd-party control, I want to detect whether the page is being loaded for the first time or as the result of a post back.  If it is a post back, I want to know if on posting the original page was valid. I tried using Page_ClientValidate() within the function, but that validates the page, and fires the RequiredFieldValidator, which isn't what I want to do at all! many thanks,    

Font on Page Becomes Bold After Javascript Alert -- Why?

In .Net 3.5   I have a web page that has several checkboxes, text boxes, dropdown boxes etc on it.  When a user clicks on the search button, I run some basic validation on the page. If any validation fails, I invoke a javascript alert letting them know what they did wrong and I return them to the page. However, when the page reloads, all of the text on the page is now larger and bold, even the text inside the menu and which resides in a master page.  I removed every instance of the word "bold" from the project but it still becomes bold after the alert fires. Any idea what could be causing this to happen?  It shouldnt matter but here is a sample of the alert I use: Response.Write("<script language='javascript'>alert('You must check at least one column to display');</script>") Any help is greatly appreciated. thanks

Getting Selected Item in radiobuttonlist on content page using javascript

I am trying get the selected value from a radiobuttonlist on a content page using javascript. Here is my initial code, which does not recognize the control. The js is located in a separate file and there is a link on the content page pointing to the js file. Thanks, function GetRadioButtonValue() { var radio = document.getElementsByName('<%=rblPayType.ClientID%>'); for (var j = 0; j < radio.length; j++) { if (radio[4].checked) { alert(); return; } else { return; } } }    

Unable to Check In Publishing Page

I am running into an issue with a custom page layout that I have created.  On this page layout I have a publishing html field, publishing image field, and a publishing summary links field.  The problem is when I check-in the publishing page as a draft the content in the publishing HTML fields does NOT save and redirects me to the root page in that web. I then checked the SharePoint ULS logs and found the following error. Time: 09/03/2010 11:47:20:18 Process: w3wp.exe (0x1248) TID: 0x0C5C Area: CMS Category: Publishing Cache EventID: 98ee Level: High Description: Trying to store a checked out item (/EN-US/MEDICALPRODUCTS/PAGES/646.ASPX) in the object cache.  This may be because the checked out user is accessing the page, or it could be that the SharePoint system account has the item checked out.  To improve performance, you should set the portalsuperuseraccount property on the web application.  See the documentation for more information. I have tried to find more answers on the web but have been unsuccessful so far.  Has anybody seen this error before or got any possible ideas to try?  Thanks in advance for any help. Craig

Client Javascript runs, but then page errors out when clicking on a control that uses postback

Using this script on a button click <script language="javascript"> function printdiv(printpage) { var headstr = "<html><head><title></title></head><body>"; var footstr = "</body>"; var newstr = document.all.item(printpage).innerHTML; var oldstr = document.body.innerHTML; document.body.innerHTML = headstr + newstr + footstr; window.print(); document.body.innerHTML = oldstr; return false; } </script> After it is done, I can't click on my calendar control.  I was hoping to add somethign that would force a refresh in the script, but nothing I do works. Any thoughts?  Thanks! 

Javascript error when attempting to switch page layouts in SharePoint 2010

I hope I put this in the correct forum. I am experiencing the following error when attempting to change the layout of an existing SharePoint 2010 page. But it does not seem to happen on all page types, just publishing pages. This error is happening on both the development server and both test servers. I have look in to the logs, since if it a javascript error there was nothing, which would be expected but I had to try. I have look at the cui.js file but was unable to spend enough time trying to figure out what exactly is going on in this file. Error being received ... Webpage error details User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; MS-RTC LM 8; .NET4.0C; .NET4.0E; InfoPath.3) Timestamp: Tue, 7 Sep 2010 21:10:54 UTC Message: Object required Line: 2 Char: 6422 Code: 0 URI: http://devintranet2010.myconexus.ca:85/_layouts/cui.js?rev=wvoVpqlQb30nGo4DjDk8Kg%3D%3D   If anyone has any ides or can point me in a direction that will allow me to productively continue my investigation, the information would be greatly appreciated. Regards Kyle

I am using the following code to check to see if a panel is visible or not before running javascript

Using VB, VS 2010, when I run the following code, I get an error because it executes the code even if I have Panel7 set to invisible.  I am trying to use javascript to see if the panel is visible or not before executing the code.var panelRef7 = document.getElementById('<%= Panel7.ClientID %>'); if (panelRef7) { $find('DragP7').add move(savePanelPosition); }  What am I doing wrong?   Thanks

execute a javascript function in code page

I use js function in source page and call that js function as below in Source page<a href="javascript:;" onclick="openwin('Sample.aspx?DID=<%#Eval("UID") %>', '', '700','300','yes'); return false ">I need to call this function from vb.net code page.....how to solve this ........???????????Give ur ideas...............

how to check javascript is enabled

hey guys, i have a wen form that has some javascript. i want to test if a user has javascript enabled or not. if they don't i should alert them with a message so they are aware they need javascript to use the form. i had a look at this example below but this will only work is javascript is enabled! any suggestions/links? <script language="JavaScript"> <!-- function cc() { if (document.cookie == "") { alert("COOKIES need to be enabled!"); document.Form1.cookieexists.value ="false" } else { document.Form1.cookieexists.value ="true" } } document.cookie = 'killme' + escape('nothing') </script>

Accordion control access in Javascript using Content page

Hi, I struggled with some javascript issues, and discovered that the problem seemes to come from a failed ajax control access.Here's my problem:I have a master page and a content page.In my content page, I have an accordion with 2 panes.1rst pane: a textbox and a validation button;                     I want the button to fire javascript function without reloading page (using "return false;");In my master page, I put my ToolkitScriptManager.In my content page, I put my script containing the functions.The problem is that it seems like I can't access the accordion control in my js functions, whereas I can access my textbox value...Here is my source:<%@ Page Language="C#" MasterPageFile="~/Default.master" Title="CLEOR RH | Home" CodeFile="Default.aspx.cs" Inherits="Default_aspx" %> <%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %> <asp:Content ID="Content1" ContentPlaceHolderID="Main" runat="server"> <script type="text/javascript"> var step1 = false; function pageLoad() { var accCtrl = $find('AccordionCtrl_AccordionExtender');

How to call javascript function in master page

helloi have javascript file 'script.js' where i have writt en a function for print. but this function is working fine if i am not using master page in my report page but the question is i want to use master page for my report page where i am calling javascript function but it is not working . Do help me regarding MasterPage and Javascript function.

How do I add an external javascript and CSS to the head of a Sharepoint page?

I am a web designer and I was asked to design a page for our internal sharepoint server. I created a spry page using Dreamweaver CS5, and I need to add the .js and .css to the head of the sharepoint document. I created the sharepoint page, and added my html code to the html webpart, the content displays, but I need to add the external files to the <head> tag so the content displays correctly. I tryed to open the page in SP Designer 2007, but I can't edit or add to the head tag. Help

JavaScript Error while calling a drill through report in a report viewer from a asp.net web page.


I am calling a report in a web page which is getting displayed in report viewer. This report comes fine but when I click on it to see the drill through report for this parent report the drill through report does not get displayed and I see a JScript error instead.

The error I get is something like,

parent.document.GetElementByID(...).ClientController is not null or not an object

The aspx page that contains the report viewer inherits from a master page that contains an Update Panel.

I tested the report separately in SSRS and the drill through is working fine there.

Can some one please provide any inputs on this one?



ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend