|
thanks for the reply - I found that I was making it way too complicated...
Condango had the solution:
to highlight from database to multiselect
where SelectedDisplayValue is the value from database(eg SelectedDisplayValue= 3,4,10)
For i = 0 To (objListbox.Items.Count - 1)
If InStr(SelectedDisplayValue, objListbox.Items(i).Value) Then
objListbox.Items(i).Selected = True
End If
Next
ublend
|
|
|
|
|
Dear All,
I want to know how to protect a file from downloading if the user is not logged in;just the way its done here on codeproject?
Suppose the file url is http://www.mydomain.com/photos.zip
Download file
Depending upon the login status it should either redirect to login page or proceed with download of the zip file, when download file link is clicked.I need the exact functionality of codeproject download feature.
Thanking you all in advance.
|
|
|
|
|
Have you tried setting the navigateUrl property based on the status of their login?
If variable <> "your logged in value" Then
Me.HyperLink1.NavigateUrl = ""
End If
ublend
|
|
|
|
|
Hi,
Buddy i forgot to mention earlier that the page is in Classic ASP as opposed to Asp.Net..Sorry for that.
Please help..
Thanks
P
|
|
|
|
|
I dug up an old (2002 old) classic ASP/VB site I created that required the user to enter a username and password, which is checked against the database. If they are successful, a session variable in the global.asa file is set to true. Each page checks the variable first and bounces the user if the variable returns false.
Top of each page:
'Check if user is logged in
Dim LoggedIn
LoggedIn = Session("LoggedIn")
If LoggedIn <> "True" Then
Response.Redirect("login.asp")
End If
global.asa
Sub Session_OnStart
'Create a Session variable to track if the user has logged in
Session("LoggedIn") = "False"
...
End Sub
Hope this helps.
Regards,
Gary
|
|
|
|
|
how are you authenticating your users? - If you are using a database to store their userID and password, you could use a script like this to signify that they are authenticated:
----use your database connection then check the form data against the data in your admin table like:
Dim myPW, username,mystatus
username=request("username")
myPW=request("myPW")
Set RSlog = Server.CreateObject("ADODB.Recordset")
RSlog.Open "Select * from Admin where username='"&myLogin&"' and password='"&myPW& "'", Conn, 2, 2
If not RSLog.eof or not RSLOG.eof then
myStatus="IN"
end if
then lower in my page, where I want active links or not, I would code something like this:
Response.Write ("<a href="yourURLorFilepath/" & RS("filename")& """>Link</a>")
else
response.write("link not available")
end if
Hope that helps. Happy coding
ublend
|
|
|
|
|
Hi ,
I am using a session variable to store my login info. Actually I am looking for a solution exactly similar to what we have on this site. I dont want to display link not available.
I have certain doc files,zip files for download where i would display the link something like http://www.mydomain.com/abc.doc but when the user clicks on this link i want then to be forced to login if not logged in.
So the problem is how to protect any link like this? If I would have been redirecting a user to any ASP page then its very easy to check the session value and then either permit or deny, but how to check on a link which directly points to a doc file or zip file ?
I hope i am not sounding like a fool
Thanks a lot for all the help so far.
|
|
|
|
|
Hi all,
Thanks a lot for your help in advance.
I am doing a Mail Merging Application. I can get all data from the source (database, file or anything) and using mail Merge fields in Word Document from C# code, I open up the word which is merged with data from database.
MS Word Document Opens –
--- should this be open in IE
--- Or should this be open as ordinary MS Word on Desktop
The problem is if I open it anyway, I loose all control over the Word Document which is opened. I don’t want to do that. I want to keep control over it and allow the Users to update the document with some standard messages which we have in the project. What that means is, the messages will be selected and those messages selected will be put at some point where cursor is kept in the document.
So, when mail merging happens
MS Word Document is opened.
A pop up with standard messages is opened.
User selects the messages he/ she wants to insert into the MS Word Document which is opened.
For these things to happen, I should have control over the MS Word Document which is opened on the client side. Do selection of the messages and populate in Word document (this is my understanding, is there any way to do it easily).
The Issues are:
I need a way to open the MS Word Document in a controlled manner where I can still control the User editing or help user in editing when he / she clicks on my standard messages and wants them to populate on the MS Word Document.
How can I save the MS Word document and make sure that user is not saving it locally and has to upload it again to save it on server.
I Hope I am clear in explaining the situation, please find the attachments which show the MS Word Doc and the popup on side .
|
|
|
|
|
Sounds like you are asking for a lot of client side javascript in order to handle it.
Maybe the approach should be more server-centric.
1) Perform the merge on the IIS server.
2) Prompt the user for messages that need to be incorporated
3) On the server, using Document automation, incorporate those messages
4) Confirm that the user wants to save the document. Save it on a server directory.
Basically, have everything under control on the server, don't try to open MS-Word on the client machine.
Just a thought.
|
|
|
|
|
Hi Iam new to C#,Asp.Net.
Iam working on building a website http://www.missmegs.com/ this site is for a restaurant.
I have this site working fine in IE but when I go to Firefox the bottom image which I used as borders for this website is coming up which is making my client little upset.
How can I overcome this issue. Iam sure this can be done with CSS and divs but I dont know how. Please help me.
Any help is greatly appreciated.
Thank in advance.
|
|
|
|
|
|
Hi
I have a listbox in aspx page and has some list in it.
Now i am trying to get the list count of the listbox from javascript.
I am trying to get that by using the following code.
function count()
{
var x = document.getElementById(<%=listbox1.ClientID %>);
var cnt = x.options.length;
}
I am using a master page here.
But the value cnt is not having any value.
I tried by using like this also
var cnt = x.length;
but still it gave me the result as undefined.
Please help me to get the count.
Thanks in advance
Naina
|
|
|
|
|
This works properly.
alert(document.getElementById('<%=ListBox1.ClientID %>').options.length);
I Love T-SQL www.aktualiteti.com
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
|
|
|
|
|
I am using a GridView and one of the fields is a DateTime. The values in this field can be null. When I call gvwDetails.DataBind() I get this error:
"String was not recognized as a valid DateTime."
I just want it to display an empty string if its a null value. It doesn't seem that hard but I have tried searching google and read a bunch of MS pages on GridViews and DataBind. The closest I have come is setting the ConvertEmptyStringToNull property in my field to true but its not doing anything. My code for the template field is:
<asp:TemplateField HeaderText="Date Due"> <br />
<EditItemTemplate> <br />
<asp:TextBox ID="txtDateDue" runat="server" Text='<%# Bind("DATE_DUE") %>'></asp:TextBox> <br />
</EditItemTemplate> <br />
<FooterTemplate> <br />
<asp:TextBox ID="txtNewDateDue" runat="server" Width="100" ></asp:TextBox> <br />
</FooterTemplate> <br />
<ItemTemplate> <br />
<asp:Label ID="lblDateDue" runat="server" Text='<%# Eval("DATE_DUE") %>'></asp:Label> <br />
</ItemTemplate> <br />
<HeaderStyle HorizontalAlign="Left" /><br />
</asp:TemplateField>
Is this really simple and I'm not seeing it? I'm sure there's some way of handling null values that I must not be seeing. Thank you for any help.
|
|
|
|
|
Cast the date to varchar or char in Query then try.
if u r using MySql then cast the date like this.
select cast(Date_Format(Date_Due,'%d %M %Y') as char) as Date_Due from table_name
if u r using Ms SqlServer then do it like this
select CONVERT(varchar(20), Date_Due, 107) AS Date_Due from table_name
You can change the date format according to requirement.
|
|
|
|
|
That works, thank you very much.
Scratch that, I had made it a bound column and forgot to change it back. When I change it back to a template field it still doesn't work.
I have found some stuff that seems helpful (like this http://stackoverflow.com/questions/584570/why-does-my-repeater-keep-crashing-on-evalnull-values[^]) but still can't get this to work with my DateTime field.
One more edit: Okay I figured it out. I had some code in my RowDataBound event that was formatting the dates and I had to modify it in the case of an empty string.
Thank you again for the help.
modified on Friday, July 10, 2009 1:02 PM
|
|
|
|
|
Hello all,
Iam new to C# and .NET but leanrt a lot while iam in here. I ran in to a situation, I have created a shopping cart application and made successfully all the way to the order confirmation. Now the client wants to reset the "Order Num" to zero on a daily basis.
i.e "Order Number" once order is placed has to start at 0 from 12 AM and has to be set to 0 at 12 PM so that they have a count on how many items they are selling per day.
How this can be achieved any help will be appreciated. Thanks in advance.
|
|
|
|
|
There are 2 obvious ways I can think of....
1 - Store the order date in the database, that way the order numbers don't need to be reset, you can simply provide a screen to display the total number of orders for a given day.
2 - Store the order date and order number in the database against each order. Create a new table called something like currentordernumber, with 2 columns date and nextordernumber, each time you create a new order query this table to get the next order number and update the table to set the nextordernumber +1. If the current date is different to the date in the currentordernumber table update the date in the table and set the order number to 1.
Option 1 is by far the best option IMO.
|
|
|
|
|
Thank you DoctorMick for a quick solution.
If I go with Option 1, there is a small issue. I also have to show the "Order Number" to the user so that they can take that to the store with them[Carry Out].
Like 7/9/09 -- orders 1 to 100. Purchaser can go a tell the restaurant for their order number that day.
7/10/09 -- order 1 to 150.
|
|
|
|
|
Well, for that reason you can add another column to the table, lets say OrderNrOfDay.
Every time you insert the order in the table, check if the date today is same as that of the last order. If yes, the increment the OrderNrOfDay else set it to 1.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Thank You Manas
That makes sense, let me try that should fix me.
|
|
|
|
|
That's again problematic. You should take extra care to make the increment atomic as multiple users will be using the web site simultaneously. Your client's idea of resetting the order numbers to 0 each day is plain stupid. In such case, how do you refer to a order? You may need order number and the day order placed.
The option 1 suggested in the other reply is good. I am not getting what is the issue you are facing with that approach?
|
|
|
|
|
I accomplished this task by creating another table which has OrderId,OrderNum, Date, OrderNrOfDay. OrderNum is the FK here to PK of orders table.
Then OrderNum from marchant warehouse is always saved in database and for clients sake generating daily order numbers starting from 1 to so on and for records we have OrderNum.
This solved the issue.
|
|
|
|
|
Hi,
Guys I have a peculiar problem here, I need to display data from two tables having no fields at all common and want to display them in one gridview on the click of a radio button .
If radiobuttton(1) is selected then data from table one will be displayed and if radiobuttton(2) is selected then data from table two will be displayed.
each of the table is having field name as:
table(1)
fname lname mname abid
table(2)
fname lname mname cdid
is there some advice you guys can help me?
thanks
|
|
|
|
|
this seems easy enough to me. Change the data source of the gridview on the event of the radio button being clicked
Christian Graus
Driven to the arms of OSX by Vista.
Read my blog to find out how I've worked around bugs in Microsoft tools and frameworks.
|
|
|
|