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

Top 5 Contributors of the Month
Post New Web Links

JQuery - Simple Cookie problem

Posted By:      Posted Date: October 20, 2010    Points: 0   Category :ASP.Net

Hi everyone,

The following code does not work as I expect.  If possible, please fix the following code for me.



var shopping_cart_id = $.cookie('ASP_NET_4_WEBSITE_3_ShoppingCartId');
if (shopping_cart_id == "") {  // not sure ????
shopping_cart_id = guid();
//Create (or update) the value of a cookie to expire in 30 days:
$.cookie('ASP_NET_4_WEBSITE_3_ShoppingCartId', shopping_cart_id, { expires: 30 });




View Complete Post

More Related Resource Links

simple wfc and ajax problem

Good day,I wrote a very basic hello world wfc/ajax solution.C#public string sayHello(string name)    {        return "Hello " + name;    }JS:function go() {            tempuri.org.IService.sayHello("John", OnSuccess());        }        function OnSuccess(r) {            document.getElementById("result").innerHTML = r;        }All the plumbing is pretty much what all the dev sites say...but I am getting a curious result.If I put a break in OnSuccess and in sayHello functions. The onSuccess is hit before the sayHello - both are hit though so the wfc seems to be working its just that the onSuccess is being called straight away rather than after the return from the server.Help appreciatedKalCODE:<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server">

best approach to a simple problem.

let me preface this with saying, i dont really know css or javascript or even xml really. i know enough to do what i need to, i dont know best practices, i can just get it done, so im aksing this to make sure the way i plan on doing this is a good way. just need to be pushed in the right direction. so im looking to make a simple webpage (client side only) that allows a user to pick colors for a IDE (think Visual Studio) so what i want to do is show a segment of code that shows something of all color types.. so think of a code segment like this response.write "hello world" there could be 4 different colors in this... the object, response, the period (it has a name, i forget it), the member, write, and a type, string.. so what im thinking is that there is some text on the page and a drop down that lets you pick the type to color, and then the color... so im thinking to use div tags to identify each type <div id=object>response</div><div id=period>.</div> etc etc and then do an on change for the color drop down to update the colors.. so i can do that, but the question is, im wanting to use CSS/XML so that way, if i get a couple of themes, i can then add a theme drop down to show some premade setups... default.xml <options> <object>red</object> <period>black</object>

Problem with jquery slidetoggle() using with repeater

Hi everyone have a problem with jquery and totally blank in jquery pls help meI have a repeater which filled from sql db<asp:Repeater ID="rpOzetveYazarlar" runat="server">        <ItemTemplate>            <style>            #fader{display:none;}        </style>        <script type="text/javascript">            $(".ToggleTikla").click(function() {            $("#fader").slideToggle("slow");            });</script>           <a  href="#">            <asp:Label ID="lblBaslik" runat="server" Text='<%# Eval("MetinBaslik") %>' ForeColor="#FF6600" Font-Bold="True" Font-Size="14px"></asp:Label></a>            <br /><asp:Label ID="Label4" runat="server" Text='<%# Ev

Simple GUI problem

So I don't know what's going on, but when I try to select a control (a textbox in my case), it only selects the lowest level control.  What I mean, is that if there is a grid, with a second grid inside, with a textbox inside of that grid - I am unable to left click the text box.  When i right click->select, it doesn't even give me the option to select the text box.  The only way I'm able to do it, is through the document outline, which is a pain. Any info will be much appreciated thanks, Phil  

ASP.NET Cookie Problem : Credential Cookie

Hello everybody. I am trying to create a cookie for storing Username and Password.This is so far I am :protected void Page_Load (object sender , EventArgs e) { if (!IsPostBack) { HttpCookie cookie = Request.Cookies["CredentialCookie"]; if (cookie != null) { string username = cookie.Values["Username"].ToString(); string password = cookie.Values["Password"].ToString(); TextBox Username = (TextBox) MasterLoginView.FindControl("UsernameTextBox"); TextBox Password = (TextBox) MasterLoginView.FindControl("PasswordTextBox"); CheckBox RememberMe = (CheckBox) MasterLoginView.FindControl("RemMeCheckBox"); CheckBox RemMyCred = (CheckBox) MasterLoginView.FindControl("RemMyCredentialCheckBox"); if (username != null) { Username.Text = username; } if (password != null) { Password.Text = password; } RememberMe.Checked = true; RemMyCred.Checked = true; } } } protected void LoginButton_Click (object sender , EventArgs e) { TextBox Username = (TextBox) MasterLoginView.FindControl("UsernameTextBox"); TextBox Password = (TextBox) MasterLoginView.FindControl("PasswordTextBox"); CheckBox RememberMe = (CheckBox) MasterLoginView.FindControl("RemMeCheckBox"); Label ErrorMsg = (Label) MasterLoginView.FindControl("ErrorM

jQuery Conflict Problem

Hi I am using three different jquery javascript files for three different control, when i integrate this three control in one page those are not working properly I think its problem of script files conflict problem. I create three different user controls in ASP.NET 2008 and then i am going to integrate it in to one page in sharepoint 2007. So any One Know what is actual problem. and how to solve it Thanks in advance

JQuery(Effects problem) With Master Page

HI friends, My project is old one it is bulit in VS2005 now i want to add the features of JQuery I m new to JQuery.I started working with simple hide and show functionality on div . It works fine with simple aspx page but  it does not work with MASTER PAGE when I apply hide and show functionality with toggle('slow'),slideup('slow'),slidedown('fast')  etc effects . I have set the property of div as runat server. Any help appreciated Regards, Chandrakant            

ajax jquery problem.

I have 3 dropdown listi am populating one depend on other fashion.ddlcountery contains list of Country names with default value as "Select Country"ddState 2 contains list of State names with default value as "Select State"ddCity contains list of city names with default value as "Select City"all country,state and city values are coming from database.When i select ddlCountry respective ddlstate will get populate.when i select ddlState respective ddlcity will ger populate.following is mu ajax jquery-------------------------------$("select#ddlCountry").change(function() {                alert("test");                var countryid = $("#ddlCountry > option:selected").attr("value");                //var url = "/User/FindSchDrv/" + ses;                var url = "FindCountryState/" + countryid;                //alert(url);                $.ajax({ &

Problem reading from cookie

I'm trying to build a smaller shop and I have run into some problems with cookies. This is my code in the shoppingcartaccess classprivate static string shoppingCartId { get { // get the current HttpContext HttpContext context = HttpContext.Current; // try to retrieve the cart ID from the user cookie string cartId = context.Request.Cookies["CartID"].Value; // HERE I GET THE ERROR // if the cart ID isn't in the cookie... // check if the cart ID exists as a cookie if (context.Request.Cookies["CartID"] != null) { // return the id return cartId; } else // if the cart ID doesn't exist in the cookie as well, generate // a new ID { // generate a new GUID cartId = Guid.NewGuid().ToString(); // create the cookie object and set its value HttpCookie cookie = new HttpCookie("CartID", cartId); // set the cookie's expiration date int howManyDays = SiteConfig.CartPersistDays; DateTime currentDate = DateTime.Now; TimeSpan timeSpan = new TimeSpan(howManyDays, 0, 0, 0); DateTime expirationDate = currentDate.Add(timeSpan); c

Weird problem with session cookie

Hi all,I'm having a weird problem with my web application, and I can't find the solution to it.I'm using a Java applet to read some data from an electronic ID. This applet posts its captured data to a HttpHandler class and stores the data back in some session variables. It all works smoothly, unless in some cases.Every time a do a new publish to the webserver or the website isn't touched for some time. There is a problem with the session.The applet can't find a session cookie, and so it crashes.I did some tests and indeed, the cookie ("ASP.NET_SessionId") does not exists. But it seems that other session variables (user login, etc) are working fine.To make sure that the cookie for the session ID is readable from the applet I do the following in the global.asax: Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs) ' Code that runs when a new session is started Dim isSessionFound As Boolean = False If Response.Cookies.Count > 0 Then For Each s As String In Response.Cookies.AllKeys If s = "ASP.NET_SessionId" Then Response.Cookies("ASP.NET_SessionId").HttpOnly = False isSessionFound = True 'just for test End If Next End If End SubI tried to do something with the isSessionFound, wh

Problem running jquery script in Content Page

Hi!! I have a master page in asp.net and a content page with some basic asp.net controls like textbox,buttons,treeview....i have a jquery script in the content page and reference set to the jquery file..The script changes the text property of a button on the keydown event set for the textbox...the script works fine if i copy and paste it in a normal page...the script only ran once when i worte it for the first time the next day when i tried to run the script it was not working..i m facing this problem for running the script in content page and i a m not aware of how to write jquery script for the content page.. i m really not finding any solution where i am wrong i have even tried setting the internet explorer security setting to low..plz plz plz plz plz plz help me on Thanks!!

update panel and jquery problem

I m working on JQuery, I have one UserControl in that I have taken one button(it is present inside an updatePanel).  when i m clicking on button on that time i want to show alert from server side for that i have written-  ScriptManager sm = ScriptManager.GetCurrent(Page); string strScript = "alert('hi')"; ScriptManager.RegisterStartupScript(this, typeof(UserControl_FrmUConFriendList), "AlertKey", strScript , true); But it is not working, if i m removing updatePanel then it is working. So plz help me. Thank's in advance.    

Simple return value from WebMethod from Ajax function using JQuery


I have an Ajax function called from JQuery that goes to a webservice to return a value.  I need a SIMPLE example on how I can do this.  I've been going nuts with serializing and every other aspect of this topic. 

I need to return either an ArrayList with ONE string field or a DataTable of some kind.  Either way, I'm populating it into a DropDownList.

I'm willing to consider alternatives to this idea. (Background info - I get a value from a textbox and I need to run it through a DB to get an associated value or set of values).  I'm being really general so that someone can show a simple example.  Thanks.

Seemingly simple URL rerouting problem


// ** URL ROUTING **  
private static void RegisterRoutes(System.Web.Routing.RouteCollection routes)  
  routes.MapPageRoute("Subsite", "{SubsiteName}", "~/Content.aspx");  
  //routes.MapPageRoute("About", "About", "~/Content.aspx");  
  //routes.MapPageRoute("Conferences", "Conferences", "~/Content.aspx");  
  //routes.MapPageRoute("PoliticsPortal", "PoliticsPortal", "~/Content.aspx");  
I am trying to register my routes as above, using a single routes.MapPageRoute() statement to cover all locations of the form www.mysite.com/subsiteName; however, I encounter all sorts of bizarre browser errors relating to my use of client-side AJAX.  If instead I use a separate "hard-coded" statement for each route, it all seems to work.

I have noticed that examples for this on the web (e.g. http://msdn.microsoft.com/en-us/library/cc668177.aspx) all seems to have at least two components in the URL path; e.g.,

routes.MapPageRoute("SalesSummaryRoute", "SalesReportSummary/{locale}", "~/sales.aspx");  
It is possible to do what I'm trying to do, isn't it?  Is there something fundamentally wrong with my approach?

IIS 7 with IE8 Cookie problem


Hi all,

   I have an issue in authentication cookie experiy date in IE and in other browsers except Firefox

The following is the web.config setting i am using

<forms name=".ASPXFORMSAUTH" timeout="30"  defaultUrl="~/Login.aspx"/>

For the above setting it is working fine with firefox the user can login into the website, but in other browsers the user cann't login into the website and i get 401 error.

Then I changed the timeout in web.config as

<forms name=".ASPXFORMSAUTH" timeout="350"  defaultUrl="~/Login.aspx"/>

Now the users are able to login into the website in all browsers.

But the problem is authentication cookie expiry time is only an hour in all browsers except Firefox.

can any one please help me on this.

thanks in advance.

Jquery for simple color picker for font color selection

I want simple jquery color picker for font(text) color selection not specific to particular textbox but to all txt boxes on form and must for font color selection not for background color .Simple color picker should like layout color selection.i want color picker like this http://wanderinghorse.net/computing/javascript/jquery/colorpicker/demo-colorpicker.html

Problem with Jquery windows modal + Validation Summary


Hi all, 

I have a jquery windows modal with some textboxes and a OK button, i have placed some field validators to 
respective textboxes with ValidationGroup. 

When the windows modal opens, the required field validator are  working when clicking on 

OK button but i cannot to visualize the error summary. 

how can i do to visualize the summary? 

thx in advance!

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