|
developerit wrote: i want the same menu as code project web site as top navigation as well as left navigation in code project website, can you give me example
Hi I do not know why You would want Your menu's to point to Code Project?
Just Kidding, I would say it was done With a combination of un-ordered-list, Css And Maybe JavaScript. Why don't You just view source in the browser?
Frazzle the name say's it all
|
|
|
|
|
|
hi
i have following line of code
randomNumber = Math.round(100000*Math.random());
url = "sample.aspx?host="+host+"&port="+port+"&targetName="+targetName+"&imageMode="+imageMode+"&randomNumber="+randomNumber;
alert("callbegins:Authentication.aspx");
location.replace(url);
alert("callends:Authentication.aspx");
break;
in the Authentication.aspx page i have the client code which connects a device. when the line of the above code getting executed it is redirecting to the URL server side but my javascript code are not working. when i call alert after replace then the page getting redirected and client code is getting excuted.
i am confused that why when putting alert after replace it is redirecting and calling client code but when the alert commented then the client code not working.
this issue is in fire fox, and in IE9 its not at all redirecting if alert also there.
please clarify me why this happens
thanks
|
|
|
|
|
I didn't take the time to look it up,
but wouldn't it be
window.location(url);
to use javascript to redirect to another page?
If it's the same page, I don't see the purpose of it.
The alert is just a message box, used for diagnosing values, or to tell the client something important.
FYI;
You need to encode the url with utf-8 or something before calling window.location(url)
|
|
|
|
|
thanks for your time & reply...
Encoding also didn't helped me. the page getting opened when i am using
window.open("URL");
but not when using
window.location.replace("URL");
|
|
|
|
|
take the double quotes off url.
I think you misinterpreted encoding. You just want to make sure that the url you create is in the correct format. encodeURI and encodeURIComponent.
But skip that for now.
window.location(url) will redirect the current page to a new page indicated by url
window.open(url) will open a new browser window, or a new tab, with the value url
it always works unless your url value has an error in it. I would have to see the string you created to see if it is a valid format.
|
|
|
|
|
url = "Authentication.aspx?host=" + host + "&port=" + port + "&targetName=" + targetName + "&imageMode=" + imageMode + "&randomNumber=" + randomNumber;
As you suggested i used as below,but that too didnt helped me out.
url=encodeURIComponent(url);
window.location.replace(url);
(Authentication.aspx%3Fhost%3D172.2.542.166%26port%3D5900%26targetName%3D172.2.542.166%26imageMode%3DColor%26randomNumber%3D79148)
this is the url i need to redirect to, i am getting break point in c# but my client side not getting executed.even i placed an alert in body onload,alert is not shown.this is happening in IE9,FF,chrome all this are HTML5 new browsers.
thanks for the reply..
modified 11-Jan-12 0:14am.
|
|
|
|
|
I need to see the url string after construction, just use alert(url);, and copy the result in this window.
Most likely, you string may be corrupt, and the function failed.
|
|
|
|
|
If you can't get construct the url, show me your header code for pointing to the js file, and post the entire javascript function. I'm taking off in 20 minutes to watch big bang theory on tv, so hurry.
|
|
|
|
|
if(xmlhttp.status == 200)
{
switch (xmlhttp.responseText)
{
//If the browser connected to remote MFP (For Anonymous connections).
case "authenticationrequired":
//Generate random number and attach it to the endpoint to avoid caching problems.
randomNumber = Math.round(100000*Math.random());
url = "Authentication.aspx?host=" + host + "&port=" + port + "&targetName=" + targetName + "&imageMode=" + imageMode + "&randomNumber=" + randomNumber;
// url=encodeURIComponent(url);
alert(url);
//
// window.open(url);
window.location(url);
default:
case...
}
}
|
|
|
|
|
It looks good.
I'd have to say in theory, that the . in the ip address are interfering, there being picked up as a special url character, so you have to encode the dots. Even if you encode the dots, there still dots.
I saw the remarked out urlencode, looks like you tried it, but it still didn't work.
I'm watching my bowling videos now, but check the valid url character set, try the encoding again, paste the results directly into the url bar, until you find something that works.
You may have to replace the dots with another char, to get it to work. try I think %20 which is a space, or an underscore _, I can't remember the encoded value for it, but there are charts on the web, url encoding %20 should find a chart.
Be back tommorow, I'm -8 GMT. I have bowling tommorrow night, so it has to be before 18:00 -8 gmt.
Edit:
I thinking that the url is a bad idea. Maybe a hidden textbox to store the ip is better.
|
|
|
|
|
Really thanks for your time & reply....
Your answers are really helped me out very well to debug depth about URL encoding cooncepts.
In the mean time i have gone through some articles about this issue and tried by returning false after a function call. And also where i am using location.replace(url). now it is working fine but yet to test in all scenarios and all browser versions.
i will get back to you on the said time tommorrow.
bye take care.
|
|
|
|
|
Oh,
That was fast.
Browsers pretty much work the same, so since it failed on all browsers means that the problem was not with the browser.
You have to encode everything you transmit, UTF8 is a set of chars from 1 to 127, that is unicode, and decode everything you receive.
asp.net is a high level wrapper, that talks to c++ code underneath, so the principles of character encoding still apply.
They don't tell you that in the books.
Have fun and go forward, your day will be productive.
jkirkerx
Oh, give me a vote, some day I might be a mvp.
|
|
|
|
|
Really thanks for your time & reply....
Your answers are really helped me out very well to debug depth about URL encoding cooncepts.
In the mean time i have gone through some articles about this issue and tried by returning false after a function call. And also where i am using location.replace(url). now it is working fine but yet to test in all scenarios and all browser versions.
i will get back to you on the said time tommorrow.
bye take care.
|
|
|
|
|
Authentication.aspx?host=172.2.542.166&port=5900&targetName=172.2.542.166&imageMode=Color&randomNumber=15563
this is the one i am getting thru alert.
thanks
|
|
|
|
|
i need help for hows to download attachment file from gridview???
|
|
|
|
|
Hi,
Please use the below code
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"
onrowcommand="GridView1_RowCommand">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="LinkButton1" runat="server"
CommandArgument='<%# Eval("url") %>' CommandName="cmd"><strong class="highlight">Download</strong></asp:LinkButton>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
For handling this on code behind, see the link below:
http://www.daniweb.com/web-development/aspnet/threads/282306[^]
-Manognya
__________________________________________________
$ God gives what is best.Not what all you wish
|
|
|
|
|
It depends on your program design first.
You can issue a postback to the server, and reload the page, while sending the file down to the browser, if the user clicks ok on the download, or you can do it on the client side using javascript, in which the page stays intact, and javascript intializes the download.
I use the javascript method now. I see no reason to issue a postback, even if it's async.
Javascript
window.open(url to file);
|
|
|
|
|
Hi friends,
i am having AJAX call in common.js , like
data type: Json and URl : sample.aspx, i have registered the user control in the aspx page(sample.ascx)... where i am registering the webservice call in Onprerender.. and binding the result into user control in onpreRenderComplete...
and getting back the result in the form of JSON in javascipt...
As i want to assign this result in to Enum... is it possible to get the response result in user control?.. or any other way to assign the result into enum in js ?
thanks and regards,
Dayakar.dn
|
|
|
|
|
Hi,
Please see the below code snippet to use the enums in javascript.
var Days = {"sunday" : 0, "monday" : 1, "tuesday" : 3, "wednesday" : 4, "thursday" : 5, "friday" : 6, "saturday" : 7};
document.write("<b>Day Names Enumerator=</b> " + Days.friday + "<br />");
Output:
Day Names Enumerator= 6
Assign the json values to the enum in the javascript.
Hope this helps.
-Manognya
__________________________________________________
$ God gives what is best.Not what all you wish
|
|
|
|
|
Yes,
You make a empty container like a panel control "<div id="container"></div>" on your webform or user control, assign an ID to the container, then the server renders the page and sends the HTML to the users browser.
You then write Javascript or JQuery to wait for the DOM to be ready. Now make the call to the web service, parse the JSON response, and use JQuery to populate the container with JQuery written HTML tags, and your JSON data.
You just need a container to populate rendered by the server, and on the client side, fill the container, but the DOM has to be ready. While the container is waiting to be populated, and progress indicator can be displayed until the web service is done.
|
|
|
|
|
Hello,
I have 2 closely related questions, would you please help.
1. In my ASP.NET MVC application, I am encapsulating the Logged In User Name within a static property in a class as
public static string LoggedInUserName
{
get
{
return HttpContext.Current.User.Identity.Name;
}
}
Now, I am wondering, as the property is static, will that value be cached so that if a new user visit the website, the last returned user's user name will be returned by the Property ? I am expecting that, every call to the property 'LoggedInUserName' the fresh new Identity value will be returned. Am not I right ?
2. If I want to cache a value within the application life cycle, I know I can use a static field. But, is it required that the static field be public ? Or any private static field is also cached within the application life cycle as well ?
Regards.
|
|
|
|
|
To the best of my knowledge, none of the code you write or compiled is cached.
You seem to have the term cache confused with the session state of the http server (web server)and the relationship of the http context that is created for each browser that connects to the http server.
|
|
|
|
|
Hi,
Thank you so much for your reply, actually I meant cache not by the Http Cache. I meant, I can keep the data live in the Memory as long as the Application is live (Web.Config is not modified or application is not restarted).
So, do you think, my Public static get accessor will return the same data for every time just because it is static ? I know if I used a static field inside the get accessor than, the value is not lost from memory.
|
|
|
|
|
No,
The data lives in the web servers session context, your just writing code that talks to the web server if the data exist. So you also need to make sure that the data exist before you ask for the data, or else the code will bomb with an object not found.
Once the session expires, usually 20 minutes, that's it, the handle to the web servers session context is deleted, and your data is cleared. You can't store session data forever, it's has a short ( finite ) lifespan.
If you want to store temporary data, then you write to the database on the server side, or write a cookie on the client side. And ask the browser for the cookie if it exist thus - Request.Cookie
3rd edit:
Don't worry about the code, or whether it is public or private. Technically, the object should already be global, in which you can access the data on another web page using the same code.
If your using the code to remember who the user is, on many pages after they sign in, then your alright. Just make sure to check the identity when needed.
modified 6-Jan-12 17:21pm.
|
|
|
|
|