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

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

How to access querystring values from javascript after url rewriting?

Posted By:      Posted Date: September 02, 2010    Points: 0   Category :ASP.Net
Hi mates, I´m using ASP.NET 3.5 with C#. The problem that I have is the following. I´m using url rewriting (in the Global.asax file) and people see urls like this:http://localhost:1855/uk/london but after I rewrite the urls I work internally with querystring values and the urls become somehting like this:http://localhost:1855/post.aspx?co=1&ci=1In my Global.asax after I create the proper url with the querystring values I just apply it with the following sentence (this is an example):Context.RewritePath("/post.aspx?co=1&ci=1");The problem is that from javascript using the following function I access the first url and not the second:function getQueryVariable(variable) { var query = window.location.search.substring(1); var vars = query.split("&"); for (var i = 0; i < vars.length; i++) { var pair = vars[i].split("="); if (pair[0] == variable) { return pair[1]; } } } I need to access the querystring values because I need to load values in a textbox using jQuery.autocomplete and Web Services. Can anyone tell me how to access the rewritten url to get the querystring values?Thanks in advance mates

View Complete Post

More Related Resource Links

How To Access Datakeys In Javascript...and How To make gridview Column Visible true in javascript


How To Access Gridview's Datakeys In Javascript...and How To make gridview Column Visible true in javascript

Reply me..

Comparing Enum values in a collection - BC42025: Access of shared member, constant member, enum mem


I am upgrading from asp1.1 to 2.0

I use collection classes to sort data (e.g in datagrids etc)


Enum newsFields
End Enum

Public Overloads Sub Sort(ByVal sortField As newsFields, ByVal isAscending As Boolean)
Select Case sortField
Case newsFields.title

Reading values from data access component individually



I am trying to pick data from the database through data access layer and use those values in different text boxes on the page.Basically on a click on the form, modal popup is planned to read the database and put the values into different text boxes which can be latter changed/ updated.

 What I am unable to do is accessing those values on the form itself progamatically. I will be thankful for any ideas and help.

My data access component is as follows:




new SqlParameter ("@reg_id", SqlDbType.Int ));"@reg_id"].Value=reg_id;try




how do i use javascript to change values of controls inside a gridview

i have 2 labels (lblRate,lblTotal) and a textbox (txtQuantity) in a itemtemplate of a gridview.I want to calculate the products of rate and quantity and show it in Total as the textbox loses focus...i cant use textchanged because i dont want the page to postback.How do i use javascript to achieve this??Please Help Urgently....<asp:TemplateField HeaderText="Rate">                <ItemTemplate>                    <asp:Label ID="lblRate" runat="server" Text='<%# Eval("Rate") %>' />                </ItemTemplate>            </asp:TemplateField> <asp:TemplateField HeaderText="Quantity">                <ItemTemplate>                    <asp:TextBox ID="txtQty" runat="server" />                </ItemTemplate>&

Changing Firefox values in about:config via Javascript

Hi WebGurus, I am currently facing a problem with Mozilla firefox JavaScript window.close() not working / does not work in firefox Is there any way of changing the values in about:config (specifically dom.allow_scripts_to_close_windows ) using Javascript, or via any other method when a page loads? Basically, I need a way of telling Firefox to close the window. If there is a better way of doing this please give me some guidelines regarding it. Thanks In Advance,Santosh

Access UserControl Control from a JavaScript Function

I have a requirement to launch a Modal Javascript dialog box from within my usercontrol,I have done this by <code> function browseControlAction(ProjID,ControlID) { strPrompt = 'Select a Previous control action..'; strOptions = 'dialogWidth:25;dialogHeight:30;status:no;resizable:yes'; selectedAction = window.showModalDialog('browseControlActions.aspx?ProjID=' + ProjID + '&Control=' + ControlID, strPrompt, strOptions); var sControl = ' + ControlID + '; if (selectedAction != null) { alert(ControlID.toString()); alert(selectedAction); var sTest = ControlID + '_txtControlAction'; alert(sTest); var sTest2 = 'txtSummary'; alert(sTest2); document.getElementById('txtCurrentControls').innerText=selectedAction;   //this works as this a control on the page itself document.getElementById(sTest2).innerText=selectedAction;      //Ditto document.getElementById(sTest).innerText=selectedAction;    //This Fails as this is the control in the USercontrol I am trying to Access //__doPostBack('',''); }</code>can anybody tell me why I can't access the Textbox control on the USercontrol?

How to access the ReportStack in the querystring of ReportViewer

Hi there, I need to find out the parent/root report  when dealing with drillthrough reports, is there an easier way of doing this ? I've had no success in trying to retrieve the ReportStack from the querystring, vs.net debugger shows Nothing even though the value is set to 1. Any help/pointers, highly appreciated.   Cheers,  

multiple querystring on javascript

hi,I am attaching a querystring into a popup window by using a javescript window.open. The problem is I cant manage to attach two or more parameters in the querystring. I am getting the values from code behind. Here's my code:<script language = "javascript" type = "text/javascript" > function i_interv() { window.open ("i_interviewscheduling.aspx?app="+<%=app%>+"&job="+ <%=job%>, "mywindow", "menubar=1,resizable=1," + "width=500,height=360,toolbars=1,scrollbars=1"); } </script> And im calling this function in codebehind by: Page.ClientScript.RegisterStartupScript(Me.GetType(), "open1", "i_interv();", True)Is there anything wrong in my code??. The popup doesnt appear when I included that querystring part. Somebody can help me here???

How to access ServerSide control Value in Javascript changed by Ajax

Hello,I have a Textbox whose value is been changed using ServerSide code (AJAX based - Partial postback) and now I want to access that changed value in JavaScript. Please suggest me that how can I access that value.document.getElementByID is displaying old value.Things work fine with full postback but are creating above issue with Partial Postback.Thanks, in Advance....

web service access from javascript

Hi,I am new to webservice accessing from javascript.I call a webmethod from javascript which returns a string array. whith this array i bind a dropdown list at client. At dropdownList selectedIndexchanged event I found there is no item in DropDownList. Is there any way how to bind the DropDownList using webMethod so that on postback i can get the dropdowns item.

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');

Access Javascript from an aspx file through another aspx file

Hello, So.. I have a file called myFile.aspx which is linked to a js file called myJS.js    There is a file linked to an entirely different frame called theOtherFile.aspx.  I want to access a function is myJS.js called myFunc in theOtherFile.aspxI am not entirely sure how I would accomplish that..I am quite new to MVC2 and JS, so I am quite confused as to how to do this.  Any suggestions would be much appreciated.~Anath

Compare initial and final values using javascript

My Page consist of  8 text box and Button named update...Initially when the page is called values are filled in to the textbox from the DB;here is wat i require1. at intial page load i want the values in of 8 textbox to stored in array in javascript .2. when pressing the button update, i need a method (javascript) to comapre the initial on load values with new values(ie if values of textbox is changed ) so           that the text box background color should displayed in different color..In Simple words ..i would like change back ground color of text box of changed values in the text box when clicking button update.please note that i would like this to be performed  by OnClientClick method of button

Access an IFrame's body tag in javascript

I want to dynamically set some attributes in an IFrame (like textAlign).  I keep getting "undefined" for all the different things I try.  When I inspect the element, it seems as though I should be able to access the html > body tag from the iFrame object, but that is not the case:var myIFrame = document.getElementById("myIFrame"); alert(myIFrame.childNodes[0]); //Expecting "Html Node", getting "undefined" myIFrame.style.textAlign = "right"; //this does nothing even though I can set the style.textAlign attribute without the javascript failing, it doesn't do anything.  Looking at Chrome's element inspector, I'm able to get the desired result by placing an inline style on the body tag within the iFrame tag.

Adding Textbox values using javascript.


Hi All,

i am developing an application using ASP.NET with C#.

in my application i have 4 textboxes. they are 1. Textbox1




Access PeopleEditor value using javascript

I had a need to do this and figured I would post my findings b/c it was a bit tricky.

Initially I tried to access the user with the following:

var names = document.getElementById('PE_CLIENT_ID').value;

where PE_CLIENT_ID is the ClientID of the PeopleEditor control.  This returned a boolean representing if there was a value in the control.

After investigating the source code for the control itself I discovered one PeopleEditor is made up of many html controls including:


How can i access claaes Property values in xml file ?



actually i am creating sitemap.sitemap is actually an xml file.And i have stored each page's url  of my project as Public shared property of a class.Now while creating sitemap xml file i want to get access to those property on my class, so that url should not be hardcoded.How can i do that ?

Please help .

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