Cookie在按钮单击事件中不起作用 [英] Cookie not working in the button click event

查看:71
本文介绍了Cookie在按钮单击事件中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!

我面临着一种奇怪的问题.我的Cookie在图像按钮单击事件中不起作用.但是,当我尝试从页面加载事件中的同一个cookie检索值时,它正在工作.请告诉我如何清除此错误??? (对象引用未设置为对象的实例.)

在shipping.aspx页面上,按钮单击事件我正在使用

Hello all!!

I am facing a strange kind of problem. My cookie is not working inside the image button click event. But when i am trying to retrieve the value from the same cookie on the page-load event it''s working . Please tell me how to remove this error ??? (object reference not set to an instance of object).

On shipping.aspx page on the button click event i am using

Response.Cookies["Ship"]["CustomerName"] = txtCustomerName.Text;



设置cookie的值.

在Final.aspx上,我正在使用imagebutton点击事件



to set the value of the cookie.

On Final.aspx on the imagebutton click event i am using

SqlCommand cmdOrder = new SqlCommand("Insert into Orders(OID,CUID,CUName,CUEmail,OPersonName,OPersonMobileNo,ODate,ODueDate,OAddress,OCity,OState,OCountry,OZipcode,OCost,OStatus,OPaidBy,OShippingCharge)values(@OID,@CUID,@CUName,@CUEmail,@OPersonName,@OPersonMobileNo,@ODate,@ODueDate,@OAddress,@OCity,@OState,@OCountry,@OZipcode,@OCost,@OStatus,@OPaidBy,@OShippingCharge)", con);
            cmdOrder.Parameters.AddWithValue("@OID", oid1);
            cmdOrder.Parameters.AddWithValue("@CUName", Request.Cookies["Ship"]["CustomerName"].ToString()); 



这里的cookiee是空的,但是如果我试图从final.aspx的pageload事件中检索相同cookie的值,则它应能正常工作.请告诉我如何摆脱这个问题



cookiee here is empty but if i am trying to retreive the value from the same cookie on the pageload event of final.aspx it''s working as it is supposed to.Please tell me how to get rid of this problem

推荐答案

google是您的朋友.问他?
google is your friend . ask him?


这篇关于Cookie在按钮单击事件中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆