|
Hi to all,
i am new in ASP.Net + C#. A Drop down list does not maintain its view state.Enableviewstate property of this dropdown is true.Please help me.
Thanx in Advance.
sachin Jangir
|
|
|
|
|
Hi there,
How do you know it does not persist its ViewState? How do you use the dropdownlist in your web form?
|
|
|
|
|
Where have you written its code to add values to dropdownlist?
and also check the postback property of the dropdownlist.
Thanks & regards,
Suresh Dayma
Everything Is Possible!
|
|
|
|
|
I am using MSSQL as my backend for ASP.Net.I have to retrieve time from SQL to ASP.Net textbox. The datatype of the field is smalldatetime. The value stored in it is "1/1/1900 12:20:00".How to Retrieve the time "12:20:00" from the field.
Sarvan.M
|
|
|
|
|
You can format the DateTime value into a string with only the time:
timeString = daTime.ToString("HH':'mm':'ss");
---
b { font-weight: normal; }
|
|
|
|
|
DateTime dtTime=Convert.ToDateTime(dateTime);
string strTime=dtTime.ToLongTimeString();
Mahendra
|
|
|
|
|
In MSSQL use Convert function:-
convert(varchar,date,108)
Saloni
|
|
|
|
|
I am having a little trouble with FormsAuthentication. I am trying to allow everyone view my default.aspx page but all other pages you must be authenticated. Do I need to have code in my web.config file that list every page? I prefer to keep everything under the root directory. Can anyone give me a quick example?
Programming is like solving a puzzle!
|
|
|
|
|
You can use the location[^] tag in the web.config file to do the trick.
|
|
|
|
|
Use these lines to drive all the users to your default page
onto the webconfig change the autenthication mode to forms
<authentication mode="Forms">
<forms loginUrl="default.aspx" protection="All"></forms>
keep Learning...
-- modified at 18:10 Monday 11th September, 2006
|
|
|
|
|
I am developing an internet site in ASP.Net and very first page of site is
default.aspx. I am using form authentication and code is as below
<authentication mode="Forms">
<forms name="ABC" path="/" loginUrl="home/default.aspx"
protection="All" timeout="30">
<credentials passwordFormat="Clear">
<user name="Scott" password="Scott" />
</credentials>
</forms>
</authentication>
As per requirement, i want to restrict users so that they can NOT directly navigate to any other page because from default page i am taking and reading user choices which will be used to generate other pages dynamically. So he has to come from default page. I don't have any sign out button in entire application because this is e-commarce site.
Now my probelm is how to expire cookie which is generated by forms authentication, when user access site from default page.
I tried number of option like
1) Expire policy on session end e.g.
Response.Cookies("Gift2IndiaAuth").Expires = DateTime.Now.AddYears(-30)
Response.Cookies("Gift2IndiaAuth").Expires = Now
FormsAuthentication.SignOut()
But no help.....Please suggest some way......
Amit
Amit
|
|
|
|
|
Probelm Resolved --by adding one more session value. This is some workaround but not the correct way...
If you know please let me know.
Cheers
|
|
|
|
|
i wanna ask about control enable me to display article this article could be
word , pdf or html file and this article must be in aportion of my page not in all the page i hope u understand my request
rasha
|
|
|
|
|
I don't know of such a control which allows to do this thing, and also basically you cannot display the contents of the word, pdf documents as part of the web page except you use the iframe element. If you mean you want to mix up the contents of the web page and the article , you may think of converting the article contents to the html markup, then output to the web page.
|
|
|
|
|
i think u r asking about open word,excel file
for that u have no need for any control
just give the path of the file and open in new window
Mahendra
|
|
|
|
|
Just learning asp.net and have a basic question.
I have a list of records that I want to display 10 at a time. I have the SQL for it but how should I do in ASP.net to send the offset where I'm currently at?
Code:
Private mNofRows As Integer = 10<br />
Private mOffset As Integer = 0<br />
<br />
Private Sub AddNavigationHandlers()<br />
Dim vLinkButtonPrev As LinkButton = DirectCast(Me.Form.FindControl("EntryNavigationPrev"), LinkButton)<br />
Dim vLinkButtonNext As LinkButton = DirectCast(Me.Form.FindControl("EntryNavigationNext"), LinkButton)<br />
AddHandler vLinkButtonPrev.Click, AddressOf EntryNavigationPrev_Click<br />
AddHandler vLinkButtonNext.Click, AddressOf EntryNavigationNext_Click<br />
<br />
vLinkButtonPrev.Enabled = mOffset > 1<br />
End Sub<br />
<br />
Public Sub EntryNavigationPrev_Click(ByVal pSender As Object, ByVal pEventArgs As System.EventArgs)<br />
mOffset -= mNofRows<br />
GetRecords(mOffset, mNofRows)<br />
End Sub<br />
<br />
Public Sub EntryNavigationNext_Click(ByVal pSender As Object, ByVal pEventArgs As System.EventArgs)<br />
mOffset += mNofRows<br />
GetRecords(mOffset, mNofRows)<br />
End Sub
I was hoping that I could have the member variables set at first time and then use them as shared to retain the value between postbacks, but this doesn't seem to work.
Should I be using the tag property of the LinkButtons?
Should I be saving the value in a session variable?
Should I be saving the value in a hidden control?
Should I be saving the value server side using a session object to hold the business tier object with state?
|
|
|
|
|
Hi,
The best place for is when calling the SQL in the first instance, for example, your sql/stored procedure should only return 10 records instead of return all the record(s).
|
|
|
|
|
I think you missunderstood me.
My SQL supports 2 parameters, number of records to return and offset from where to return records. EX: Nof=10, Offset=10 will return records 10-19. I will olny return the number of records that I need from the data-tier.
My question is when hitting the linkbutton "next 10 records" and the postback fires, how do I remember the offset variable. For each time I press the "next 10 records" I want to offset counter to increment by 10.
In old ASP I would have submitted the Offset parameter as an appended querystring parameter:
Ex: <a href="List10Records.asp?intOffset=10">next 10 records</a> . How should I do in ASP.net 2.0?
|
|
|
|
|
use page data source. It has currentindex property.
I hope this help you.
Amit
|
|
|
|
|
I should say that I'm not using databinding.
I'm surprised that I havn't got more replies to this as I thought that this would be a simple question.
I will look at the page data source control but I see this as a more general question, to retain a value between postbacks.
I tought the whole idea with code behind was to allow the programmer to utilize more of the same programing thechniques as when writing a WinForms application. I'm surprised that ASP.net cannot handle member variables. Why arenä't these stored and re-initalized by the view state as a controls properties?
|
|
|
|
|
Hi guys
What is wrong with this ReportPath: /Pages/ReportViewer.aspx?Website+Reportingfvisits&rs:Command=Render
FYI: ReportServerUrl: http://server/ReportServer/
I get the following error: The path of the item "/Pages/ReportViewer.aspx?Website+Reportingfvisits&rs:Command=Render" is not valid. The path must be less than 260 characters long and must start with slash. Other restrictions apply. (rsInvalidItemPath)
|
|
|
|
|
HOw can add new record with ASP.NET without using SQL Statement and Dataset?
Thanks
................
|
|
|
|
|
|
Let me explain.
GetExcludeFolder() - Gets from XML folders that has to be excluded, that's ok.
To enable paging, first I have to fill the array and then display the data from an array as I did in foreach.
The problem code is if statesment.
It says if s.Name doesen't have any string that GetExcludeFolder() returns, then fill the array with this folder name otherwise dont fill array.
When I run this, I get all folder from wwwroot.
Iam confused, what Iam doing wrong?
protected override void Render(HtmlTextWriter writer)
{
int i = 0, j = 0;
DirectoryInfo dir = new DirectoryInfo(@"f:\inetpub\wwwroot\");
DirectoryInfo[] d = dir.GetDirectories("*");
foreach (DirectoryInfo s in d)
{
if (s.Name.IndexOf(GetExcludeFolder()) == -1)
{
directory[i, j] = s.Name.ToString();
directory[i, j + 1] = s.CreationTime.ToString();
i++;
}
}
Response.Write("<table cellpadding=\"0\" cellspacing=\"0\" border=\"1\" width=\"100%\">");
Response.Write("<tr>");
Response.Write("<td style=\"height: 25px; width: 50%;\">Folder name");
Response.Write("</td>");
Response.Write("<td style=\"height: 25px; width: 50%;\">Date created");
Response.Write("</td>");
Response.Write("</tr>");
j = 0;
for (i = currentPage * pageSize - pageSize; i < currentPage * pageSize; i++ )
{
Response.Write("<tr>");
Response.Write("<td style=\"height: 25px;\"><a href=\"http://localhost/" + directory[i, j] + "/\">" + directory[i,j]);
Response.Write("</a></td>");
Response.Write("<td style=\"height: 25px;\">" + directory[i,j + 1]);
Response.Write("</td>");
Response.Write("</tr>");
}
Response.Write("<tr>");
Response.Write("<td style=\"height: 25px\" colspan=\"2\">");
Response.Write("1 2 3");
Response.Write("</td>");
Response.Write("</tr>");
Response.Write("</table>");
}
|
|
|
|
|
You use a lot of variables that you (hopefully?) have defined outside the method. For instance, where, when and how do you create the directory array?
What does the GetExcludeFolder() method return? Why do you use IndexOf to compare it with the Name property?
---
b { font-weight: normal; }
|
|
|
|