|
hi
i wanted to implement sessions in my application... i wrote the following code on the login page
if (dread.Read())<br />
{<br />
Session["user"] = uname.Text;<br />
Response.Redirect("MainP.aspx");<br />
}
then on the page load event of the following pages i wrote this code..(used master pages.though)
<br />
if (!IsPostBack)<br />
{<br />
if (Session["user"] != null)<br />
{<br />
Label1.Text = Session["user"].ToString() + "!!";<br />
Response.Cache.SetExpires(DateTime.Now.AddSeconds(0));<br />
Response.Cache.SetCacheability(HttpCacheability.NoCache);<br />
Response.Cache.SetValidUntilExpires(true);<br />
<br />
}<br />
else<br />
{<br />
Response.Redirect("login.aspx");<br />
string uname = (string)(Session["User"]);<br />
}<br />
}
Now the problem is that, if i dont login, no page will open, if i type the URL, but afted logout, on BACK BUTTON press of the web browser, the page opens, instead of getting redirected to login page.
any ideas..
then i created a LOGOUT LInk Button, and wrote the following code...
protected void LinkButton1_Click(object sender, EventArgs e)<br />
{<br />
Session.Abandon();<br />
Session.Clear();<br />
Session["user"] = null;<br />
Response.Redirect("login.aspx");<br />
}
Kunal
|
|
|
|
|
Hi,
Put the following piece of code on every page, outside of postback check
if (Session["user"] == null){
Response.Redirect("login.aspx");
string uname = (string)(Session["User"]);
}
Mubashir
Every job is a self portrait of the person who did it.
|
|
|
|
|
not working.. that back button still gets me to the page.. is there a problem with the logout link button code..??
Kunal
|
|
|
|
|
Kunal P wrote: Response.Cache.SetExpires(DateTime.Now.AddSeconds(0));
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.Cache.SetValidUntilExpires(true);
Move the above code to the beginning of the Page_Load Event.
|
|
|
|
|
Hi guys
i want to create a asp.net application which can listen to incoming TCP/IP packets. It should be able to send commands to a remote IP system and get reply from there. The remote system can be a hand held device.
Can anyone help me to get and manage IP packets . I am using c# and asp.net
Regards
Hari
|
|
|
|
|
Hello guys/gals:
Background:
I have a C# desktop application that uses SOAP to pull information from a web service located somewhere on the LAN. The need has arisen, for my application to also be able to send data back to the service, meaning that the request is initiated at the server end.
So after some initial research, it seems as though I need to create a web service on my end that listens for such requests. However, I'm still a bit confused on whether this is the route to take. So I was hoping on getting some help from fellow developers with web services experience:
Questions:
1) Is it even necessary for me to create a web-service, or is there a way that my application can still remain a client and still be able to respond to requests initiated by the server on the other end via SOAP?
2) If I do have to create a web service on my end, is there a way to control that web-service from within my C# application? (e.g. starting/stopping the service, access to its data members and methods)? Basically the following:
*My Web Service Receives Request -->My Desktop App is aware of that request and gathers the data<br />
<br />
*My Desktop app passes the data to the web service-->My Web Service Replies<br />
Sorry for the long post, and thanks for your help!
-- modified at 20:35 Saturday 7th April, 2007
|
|
|
|
|
Hello.
am trying to set a value from aspx.cs page (string str) and then want to access that value in the aspx page.
Please let me know how to do that.
|
|
|
|
|
Hi,
- Declare your variable as public in the aspx.cs
- in your .Aspx use : <%=myVar%> in any place
HTH
Hayder Marzouk
|
|
|
|
|
Hi all,
I use DetailsView Object in ASP.NET.
It dosen’t appear until the refresh button in IE clicks.
I set the DataSource Property and use the DataBind Method.
What i can do?
|
|
|
|
|
would you like to post your code with the event you are using to perform tis task?
|
|
|
|
|
Hi
This is my code
asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" Height="40px"Style="direction: rtl" Width="472px"
Fields
asp:BoundField DataField="Employer" HeaderText="کارفرما"
asp:BoundField DataField="Advisor" HeaderText="مشاور"
asp:BoundField DataField="StartTime" HeaderText="زمان شروع"
asp:BoundField DataField="EndTime" HeaderText="پیش بینی تاریخ اتمام پروژه"
asp:BoundField DataField="TimeAgreement" HeaderText="مدت قرارداد به ماه"
asp:BoundField DataField="State" HeaderText="محل اجرا"
Fields
asp:DetailsView>
asp:SqlDataSource ID="SQLDS_ALLV_TitleIE" runat="server" ConnectionString="<%$ ConnectionStrings:SamanMohitConnectionString %>"
SelectCommand="ALLV_TitleIE" SelectCommandType="StoredProcedure"
SelectParameters
asp:ControlParameter ControlID="Label1" Name="F_Title" PropertyName="Text" Type="String"
asp:Parameter DefaultValue="فارسی" Name="F_Language" Type="String"
SelectParameters
asp:SqlDataSource
I use the "<"and "/>" in my code
And this is runtime code
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If (Application("SN") = "Agreement") Then
Label1.Text = PreviousPage.mText1.Text
DetailsView1.DataSource = SQLDS_ALLV_TitleIE
DetailsView1.DataBind()
ElseIf (Application("SN") = "News") Then
Label3.Text = PreviousPage.mText1.Text
DetailsView2.DataSource = SQLDS_NL_Title
DetailsView2.DataBind()
End If
LinkButton1.CommandName = Application("Search")
End Sub
-- modified at 0:48 Sunday 8th April, 2007
|
|
|
|
|
سلام
اگر فارسی می نویسیم به این دلیل است که از نوع عناوین جنابعالی فهمیدم که ایرانی هستید.
به هر حال برای Bind کردن DetailsView با این روشی که شما انتخاب کرده اید و از SqlDataSource استفاده می کنید، برای گرفتن نتیجه باید از DetailsView1.DataSourceId استفاده کنید درضمن هنگام تعریف DetailsView میتوانید در کد های HTML نیز این مشخصه را تعیین نمایید برای مثال:
asp:DetailsView ID="dtl1" DataSourceId="SQLDS_ALLV_TitleIE" runat="server" ..... /asp:DetailsView
در ضمن بهتر است دستور Select شما حاوی شرطی باشد که موجب برگرداندن یک رکورد شود.
اگر هم با SqlDataSource مشکل دارید می توانید از DataTable استفاده کنید.
البته با عرض معضرت باید بگویم که روشی که شما انتخاب کرده اید با مراجعات متعدد به سایت رفته رفته از سرعت آن کاسته خواهد شد یعنی خاصیت SqlDataSource چنین است که در هر بار PageLoad اجرا شود در حالی که شما فقط به یکی از SqlDataSource ها نیاز دارید ولی در هر بار هر دوی انها اجرا خواهد شد که این روش خوبی نیست.
به هر حال اگر به نتیجه نرسیدید اگر کمکی از دست من بربیاید یا در همین سایت و یا به آدرس abolfazl585@yahoo.com میل بزنید.
باتشکر
We Can Do Anything, If We Want It
|
|
|
|
|
Hi all,
I use Application object in ASP.NET.
I set it’s value in one page and read it in another page but I don’t know when I can dispose this object in order to in the first page it’s not set and if an event accord it set again.
Thanks in advance
|
|
|
|
|
You should only use the application object for things you want to keep across user sessions. Like some sort of static data that all users would be looking at. It sounds like you should be using a session variable to pass things from one page to the next. Session is very similar to the application object except it is only for that user, other users can see that object, they can only see their own session object.
Either way if you want to remove and object from the session or application you can just set it to null or Nothing in vb.net. There is also a Remove method in the object to remove something from the application or session object.
Hope that helps.
Ben
|
|
|
|
|
When i can use it?(What event)
|
|
|
|
|
You can use the session and application object anywhere in the codebehind. All events have access to it.
Ben
|
|
|
|
|
I use it in Finalize Method of the page but in order to access again to it i don't know What i can?
|
|
|
|
|
Perhaps it is better for you to explain what you are trying to do and then I might be able to suggest something for you to try. Finalize method of the page seems like a strange place to set a variable in session or application. Most of the time I set it in th page load event.
Ben
|
|
|
|
|
Hi
I have a dropdownlist where the user.the user will select the name of the project from.Please help me with the code for my problem.........
************
After the user selected the project Name on my listbox display the name of all the Project Members working under that particular project.
Please help me
oga m
|
|
|
|
|
Hey that is very simple.
What you have tried so for?
What is the Error you are getting?
Regards,
Satips.
|
|
|
|
|
first u`ll need to execute a select query where in u`ll select on the bases of the project selected from the drop down list such as
"Select * from project where projname = '+ddwlist.selectedvalue+'
then u`ll populate ur listbox like this
while(rd.read)
{
listbox1.items.add(rd["projmembers"].tostring)
}
i hope this solves ur problem
Kunal
|
|
|
|
|
Hi Guys
I'm actually very confused.Is it possible that I can use both CommandField and CheckBoxField in my GridView
oga m
|
|
|
|
|
yes, thas is very easy
<asp:CommandField ButtonType="Link" />
<asp:CheckBoxField DataField="yourFiled" />
.
.
.
if this code dont help you, please say me your question in good question
-- modified at 3:46 Monday 9th April, 2007
We Can Do Anything, If We Want It
|
|
|
|
|
I am using namespace system.io
in that i am taking file and deleting it.
File.Delete(filename);
it gives error access to this file is denied for few files rest files it is deteting.
can someone please help me out ??????
thanks in advance .
|
|
|
|
|
You have to grant WRITE permission for asp.net account, I think
<< >>
|
|
|
|