Can any body tell me how to retrieve the value of variable that is passed like this that i have mentioned above then how to retrieve thsi value through javascript.
Maybe you can drop it on your page as a Javascript variable from the server side.
In my example, I needed access to the hidClient and hidUser_Id from Javascript. I did it this way because the hidden vars were located inside a FormView control (Asp.Net manipulates ID property at runtime so I created a special var to access them).
rob, you could have just used a html hidden input with a runat=server attribute and set the value of that. Much less code to achieve the same result of having a value available clientside
prashant_vic...
Participant
1155 Points
437 Posts
Retrieving querry string variable using javascript
Jun 19, 2006 11:23 AM|LINK
Hello
I have two webpages w1 and w2,
on w1 ihave a button when i'll click on this button a next page is displayed through this coding,
Window.open('w2.aspx?id=hello','','')
On the load of page w2 i want to retrieve the value of variable id that is passed in the querry string,
I am able to do this in the codebehind file through vb
like this
Dim a as string
a=Response.Params("id")
This working fine But i want to retrieve the value of this id through javascript
I have tried this but this is not working.
<
script language="javascript" type="text/javascript">function
OK(){
var
name= Request.QueryString("id");alert(name);
}
</
script>Can any body tell me how to retrieve the value of variable that is passed like this that i have mentioned above then how to retrieve thsi value through javascript.
stevef200
Member
635 Points
123 Posts
Re: Retrieving querry string variable using javascript
Jun 20, 2006 08:29 AM|LINK
add the following javascript to the page and then you can query the querystring by using
var qs = new Querystring()
var v1 = qs2.get("id")
copy and paste this into a <script> block inside your head tag
function Querystring(qs) { // optionally pass a querystring to parse
this.params = new Object()
this.get=Querystring_get
if (qs == null)
qs=location.search.substring(1,location.search.length)
if (qs.length == 0) return
// Turn <plus> back to <space>
// See: http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.13.4.1
qs = qs.replace(/\+/g, ' ')
var args = qs.split('&') // parse out name/value pairs separated via &
// split out each name=value pair
for (var i=0;i<args.length;i++) {
var value;
var pair = args[i].split('=')
var name = unescape(pair[0])
if (pair.length == 2)
value = unescape(pair[1])
else
value = name
this.params[name] = value
}
}
function Querystring_get(key, default_) {
// This silly looking line changes UNDEFINED to NULL
if (default_ == null) default_ = null;
var value=this.params[key]
if (value==null) value=default_;
return value
}
.Net Consultant
prashant_vic...
Participant
1155 Points
437 Posts
Re: Retrieving querry string variable using javascript
Jun 20, 2006 01:48 PM|LINK
Hello Steve ,
Thanks for replying,
I have also found a good article abt my problem of Querry string,
Take a look,
http://javascript.about.com/library/blqs.htm
Byeeeee and Take care
robertmazzo
Participant
1027 Points
323 Posts
Re: Retrieving querry string variable using javascript
Jun 20, 2006 02:34 PM|LINK
In my example, I needed access to the hidClient and hidUser_Id from Javascript. I did it this way because the hidden vars were located inside a FormView control (Asp.Net manipulates ID property at runtime so I created a special var to access them).
StringBuilder cJavaScriptCode = new StringBuilder();
// CREATE JAVASCRIPT VARS HERE !
cJavaScriptCode.Append("<SCRIPT language='javascript' type='text/javascript'>");
cJavaScriptCode.AppendLine();
cJavaScriptCode.Append("var hidClientAliasID = '" + hidClient.ClientID + "';");
cJavaScriptCode.AppendLine();
cJavaScriptCode.Append("var hidUser_IdAliasID = '" + hidUser_Id.ClientID + "';");
cJavaScriptCode.AppendLine();
cJavaScriptCode.Append("</script>");
if (!Page.ClientScript.IsClientScriptBlockRegistered(typeof(Page), "objUserFilterAliases"))
{
ClientScript.RegisterClientScriptBlock(this.GetType(), "objUserFilterAliases", cJavaScriptCode.ToString());
}
stevef200
Member
635 Points
123 Posts
Re: Retrieving querry string variable using javascript
Jun 20, 2006 02:55 PM|LINK
.Net Consultant
magnum88
Member
8 Points
10 Posts
Re: Retrieving querry string variable using javascript
Jul 30, 2009 06:07 AM|LINK
????
where is the value of the hidClient.ClientID or hidUser_Id.ClientID?
magnum88
Member
8 Points
10 Posts
Q:WEBSITE REWRITE AND MIRROR DOMAIN NAMES PLEASE ANSWER ASAP! TNX
Jul 30, 2009 06:09 AM|LINK
Hi,
how would you know if a website url is rewrite?
and
How would you know if a url has a mirror domain names?
what are the keywords use?
How would i code it in ASP.NET C# webpage....
Thanks
regards
magnum88
magnum88
thanks