|
You will need to do this yourself when you enter the method. You need to use reflection to see if the method has the attribute and take the appropriate steps if it does or doesn't.
The functionality you describe isn't implemented in the attribute at all. It is implemented by the calling method. Keep in mind that some of this behavior is intrinsic to the .NET runtime itself and checking security permissions like this should be part of the runtime function calling behavior.
|
|
|
|
|
I'm trying to set with filetype there are aloud to be when your are uploading.
I gett this errormessanger: CS1525: Invalid expression term '.'
The line thats error:
Line 10: string StrFileType = File1.PostedFile.ContentType(.JPG | .PNG)
The hole code:
void UploadFile(object Sender,EventArgs E)
{
if (File1.PostedFile !=null)
{
/
string StrFileName = File1.PostedFile.FileName.Substring(File1.PostedFile.FileName.LastIndexOf("\\") + 1) ;
string StrFileType = File1.PostedFile.ContentType(.JPG | .PNG) ;
int fileSize = (int)Math.Round((double)File1.PostedFile.ContentLength / 1024, 0);
int maxSize = 1024;
if (fileSize > maxSize)
Response.Write(" Uppladningen misslyckades! Storlek får högst vara 1mb ");
else
{
File1.PostedFile.SaveAs(Server.MapPath("img\\" + StrFileName));
lblUploadedFileName.Text ="Länken till bilden: http://domain.com/se/img/"+StrFileName;
lblbbcode.Text ="BBCode: [img]http://domain.com/se/img/"+StrFileName + "[/img]";
}
}
}
Frozzare, Segeltorps Scoutkår
www.segeltorps.scoutkar.nu
|
|
|
|
|
You might want to try putting quotes around the items in the ContentType. At the moment, the code looks as though it's a constant.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Then i get this errormesseanger:
CS0118: 'System.Web.HttpPostedFile.ContentType' is a 'property' but is used like a 'method'
Frozzare, Segeltorps Scoutkår
www.segeltorps.scoutkar.nu
|
|
|
|
|
It's bad karma getting you for posting a programming question in the lounge.
_____________________________________________
Flea Market! It's just like...it's just like...A MINI-MALL!
|
|
|
|
|
hi
String fileExt =
System.IO.Path.GetExtension(this.File1.FileName).ToLower();
ramana
|
|
|
|
|
I have a simple text box and a button when i click on a button the data must be saved to a table in sql how it can bedone
sas
|
|
|
|
|
|
SqlCommand myCommand = new SqlCommand("INSERT INTO Designation (Designation) " + "Values ('string')", myConnection);
the problem is in this line how to insert a text box value in the values place
sas
|
|
|
|
|
sajid.salim.khan wrote: SqlCommand myCommand = new SqlCommand("INSERT INTO Designation (Designation) " + "Values ('string')", myConnection);
the problem is in this line how to insert a text box value in the values place
What about myTextBox.Text? That'll give you the contents of the textbox.
It isn't enough to do well in life.
One must do good when and where one can.
Otherwise, what's the point?
|
|
|
|
|
i have done that but how to placeit in the value of mycommand parameter
SqlCommand myCommand = new SqlCommand("INSERT INTO Designation (Designation) " + "Values HERE ('string')", myConnection);
sas
|
|
|
|
|
programmer can learn only by googling around in MSDN or somethng like this. Dont, expect direct answer in CodeProject.Try somethings by yourself...
Regards
Chintan
www.visharadsoft.com
(I am thinking to change humans to computer, but unfortunately GOD will not give me the source code)
|
|
|
|
|
Anyone know how to do it? I need to figure out a way to run all of the unit tests under a specific namespace using C#.Net 2.0
--
"Keyboard not found. Press < F1 > to RESUME. "
Source unknown (appears in many common BIOSes as a real error message)
|
|
|
|
|
How to find a particular cell value in GridView RowUpdating event.
protected void GridView1_RowUpdating(object sender, GridViewUpdateEventArgs e).
Please suggest.
Thanks
|
|
|
|
|
|
Hi,
I have a label and a tooltip associated with it.
If i hold the mouse over it and after a while the tooltip disappears.
string data = "hello world";
tip = new ToolTip();
tip.AutoPopDelay = 1500000;
tip.InitialDelay = 50;
tip.SetToolTip(this, data);
When i hold the mouse over the label again nothing is shown.
Is there a property or something to make it appear everytime i hold the mouse over
or shall i create the tooltip one more time?
Thanks!
|
|
|
|
|
I think u have not understand all its property. Try updating AutoPopDelay prty.This wil giv u the solution...
Regards
Chintan
www.visharadsoft.com
(I am thinking to change humans to computer, but unfortunately GOD will not give me the source code)
|
|
|
|
|
I've done some googling, but haven't turned up any answers to my questions - can anyone help?
1) My application reads comma delimited records from a file. The read and split is very fast indeed, but after they've been read I need to create objects out of the records, do some validation etc. etc. This can take a while to complete for large record sets. Aha, says I, multiple threads can speed this up.
My plan is to have one thread read the file and then place the returned string array in to a queue. Then as many worker threads as needed can dequeue an individual array in the queue and go off to do its work.
First up - is this a sensible approach, or is it a real stinker of an idea and are there better ways to achieve the same?
2) Is dequeuing thread safe, or could two threads attempt to dequeue the same item in the queue?
3) Are there any guidlines on the number of threads one should spawn for a given processor type? My PC has a Quad Core in it, which I assume means that things really can happen concurrently. My users, however, may well be limited to single core processors which I think will mean that the threads will share processor time - could too many threads in this situation lead to much slower performance as they all vie for time?
Thanks.
Me: Can you see the "up" arrow?
User:Errr...ummm....no.
Me: Can you see an arrow that points upwards?
User: Oh yes, I see it now!
-Excerpt from a support call taken by me, 08/31/2007
|
|
|
|
|
Martin - I'm going to point you towards the excellent SmartThreadPool[^] component here. It will help give you all the information you need to get started.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Magic - thanks Pete.
Me: Can you see the "up" arrow?
User:Errr...ummm....no.
Me: Can you see an arrow that points upwards?
User: Oh yes, I see it now!
-Excerpt from a support call taken by me, 08/31/2007
|
|
|
|
|
martin_hughes wrote: Aha, says I, multiple threads can speed this up.
Even under conditions where it would it might be insignificant.
martin_hughes wrote: could too many threads in this situation lead to much slower performance as they all vie for time?
There are many issues that come into play like overhead for context switching and cache misses etc. Actually two threads could cause that to happen and unless yours is the only process running on a multi processor/core computer (very unlikely it is the only one) it may not get access to more than one core and could also result in reduced performance.
Multi-threading in a single user application is mostly (not always) applicable to keeping the UI from freezing during a long running process like graphics manipulation or interprocess communications, etc. Otherwise threads are mostly useful in a multi-user environment.
|
|
|
|
|
Hi all,
I've written a program where part of it will print a selected file to a printer. This file has tabs in certain places that are crucial to the output not looking wonky.
The output looks wonky. However, if I print it up using something like Notepad, it looks just fine. I'm using a generic filestream/printer handler to do the job. Is there a way for the tabs to be preserved?
Thanks for your time,
Michael Fritzius
OpenFileDialog fdlg = new OpenFileDialog();<br />
fdlg.Title = "C# Corner Open File Dialog";<br />
fdlg.InitialDirectory = @"C:\ ";<br />
fdlg.Filter = "Text files (*.txt | .txt | All files (*.*) | *.*";<br />
fdlg.FilterIndex = 2;<br />
fdlg.RestoreDirectory = true;<br />
if (fdlg.ShowDialog() == DialogResult.OK)<br />
{<br />
textBox1.Text = fdlg.FileName;<br />
}<br />
string filename = textBox1.Text.ToString();<br />
reader = new StreamReader(filename);<br />
verdana10Font = new Font("Arial", 10);<br />
PrintDocument pd = new PrintDocument();<br />
pd.PrintPage += new PrintPageEventHandler(this.PrintTextFileHandler);<br />
pd.DefaultPageSettings.Landscape = true;<br />
<br />
pd.Print();<br />
if (reader != null)<br />
{<br />
reader.Close();<br />
}
-- modified at 14:41 Friday 21st September, 2007
|
|
|
|
|
Well - part of your problem is that you are using the Arial font (which is proportional) and Notepad uses a fixed width font.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Pete O`Hanlon wrote: Notepad uses a fixed width font
by default, but you can choose any available font ...
Luc Pattyn [Forum Guidelines] [My Articles]
this weeks tips:
- make Visual display line numbers: Tools/Options/TextEditor/...
- show exceptions with ToString() to see all information
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I'm not sure if that's going to help, because I'm not wanting to even use Notepad to print up these files. The problem is whenever the file is printed, the tabs that would normally keep things spaced out evenly are replaced with whitespaces.
The printer handler I'm getting ready to show basically takes each line from a file and turns it into something that the printer can understand. It does it line by line but makes no provision for tabs. Can you show me how to modify this?
Thanks for your time,
Michael Fritzius
private void PrintTextFileHandler(object sender, PrintPageEventArgs ppeArgs)<br />
{<br />
Graphics g = ppeArgs.Graphics;<br />
float linesPerPage = 0;<br />
float yPos = 0;<br />
int count = 0;<br />
float leftMargin = ppeArgs.MarginBounds.Left;<br />
float topMargin = ppeArgs.MarginBounds.Top;<br />
string line = null;<br />
linesPerPage = ppeArgs.MarginBounds.Height / verdana10Font.GetHeight(g);<br />
while (count < linesPerPage &&<br />
((line = reader.ReadLine()) != null))<br />
{<br />
yPos = topMargin + (count *<br />
verdana10Font.GetHeight(g));<br />
g.DrawString(line, verdana10Font, Brushes.Black,<br />
leftMargin, yPos, new StringFormat());<br />
count++;<br />
}<br />
if (line != null)<br />
{<br />
ppeArgs.HasMorePages = true;<br />
}<br />
else<br />
{<br />
ppeArgs.HasMorePages = false;<br />
}<br />
}
|
|
|
|