|
Look into these methods for running javascript from within your asp.net app.
RegisterClientScriptBlock()
RegisterStartupScript()
-Richard
|
|
|
|
|
One thing you can do is compile the JavaScript code as JScript.NET (look at jsc.exe compiler in the DotNet SDK).
Once compiled as .NET code, C# code could call the JScript.NET functions without hassle.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: He has a funny face. And he's my son.
Judah Himango
|
|
|
|
|
Hello everyone. I have an interesting problem that I need help with. I'm sure someone else has already had this problem. I have a custom control (either win or web because I have both doing this) and this control contains other controls such as a label and richtextbox. Well I have a few public properties that set properties on the internal controls but I also have a property that exposes the internal control as a property. My problem is that when I goto the designer and set properties though the control exposed though the property none of the settings are kept, however if I set the properties on the exposed control in code behind everything works fine.
Any help would be apprciated
-Richard
|
|
|
|
|
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] makes sure it is saved - put that in front of your control property
|
|
|
|
|
if u have custom properties on that control property, be sure to use [DefaultValue(false)] on the properties if they are primitive types (int,string etc.).
If u have object properties use the [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] attribute and go into that object and use the [DefaultValue(false)] attribute.
etc. etc.
|
|
|
|
|
I have an RTF which is being used do text editing. When an existing text document is placed in the control, it automatically adjusts lines based on the text fitting inside the window. However when I issue a editWindow.GetLineFromCharIndex() it returns a line number (3 for example) which is outside of the internal editWindow.Lines property within the control.
So line 3 may visually be the 3rd line of text. Yet internally all of the text only exists on line 1.
Is there any way to get the Lines property of the RTF to match the visual lines created via WordWrap???
Thanks!
There are 10 kinds of people in the world.
Those that read binary...
...and those who don't.
|
|
|
|
|
I am new to C# and looking for a little help. I need to programmatically
add users "User Logon Name" / "WinNT logon" to the windows 2000 Active Directory. I need to control/add other properties, but for now this is the main objective.
I have successfully added pre-Windows 2000 users with DirectoryEntry & NetUserAdd, but can't find the syntax to add a WinNT logon name.
I am using Visual Studio.Net 2003
Thank you,
markaelkins@gmail.com
Other properties that I need to control/add: (password, Full name, pre-Windows 2000 logon, User cannot change password, Password never expires, Description, Office)
|
|
|
|
|
I have a progress bar. I would like to display a transparent label OVER the progress bar to show the % completed. It seems like all of the techniques related to creating a transparent label only make the label's background transparent relative to its parents background rather than relative to any sibling controls that might be draw UNDER it. Does anyone know of a way to draw a transparent label so that the text area of the label displays the content under the label rather then the background color of the parent container?
thanks.
|
|
|
|
|
A more appropriate way would be to extend the ProgressBar control and draw the label yourself. Putting a transparent control over it will require owner drawing anyway (to mask out everything but the text, which isn't easy if you want anti-aliased text) and will require more memory since another control is required (controls are windows and too many is very expensive).
So, extend the ProgressBar class and draw the text in the middle like so (just a basic example):
public class ProgressWithText : ProgressBar
{
Brush textBrush;
public ProgressWithText()
{
SetStyle(ControlStyles.UserPaint, true);
textBrush = new SolidBrush(ForeColor);
}
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
e.Graphics.DrawString(Value.ToString() + "%", Font, textBrush,
(RectangleF)Bounds);
}
protected override void OnForeColorChanged(EventArgs e)
{
base.OnForeColorChanged(e);
if (textBrush != null)
textBrush.Dispose();
textBrush = new SolidBrush(ForeColor);
}
} If you want to change the color of part of the text when the actual progress bar moves under the text, you should consider painting the whole thing (easier in the long run), which isn't too hard. Search for "progress bar" on this site for a number of good articles about owner-drawn progress bars.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks, however when I go to compile this code, the compiler tells me that I can't inherit from ProgressBar because the class is sealed.
|
|
|
|
|
Hmm...so it is. I must apologize. I've never had a reason to extend it and other controls are sealed that I have extended. Progress bars are very easy to create. Please follow my suggestion to search this site for "progress bar" and you'll find lots of articles how, including progress bars with gradients, custom pictures, and more; some even provide sample code that shows how to draw the percentage text (similar to how I did it above).
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi
I'm having an error "A generic error occurred in GDI+." with the following image resize code. can anybody help. PLZ
private void cmdStart_Click(object sender, System.EventArgs e)
{
if (( File1.PostedFile != null) && (File1.PostedFile.ContentLength > 0))
{
//determine file name
string szFileName = System.IO.Path.GetFileName(File1.PostedFile.FileName);
Size s = new Size(75,75);
ImageResize(File1.PostedFile.FileName,s);
}
}
void ImageResize(string str_file, Size new_size)
{
try
{
System.Drawing.Image src_image = System.Drawing.Image.FromFile(str_file);
Bitmap bitmap = new Bitmap(new_size.Width, new_size.Height,src_image.PixelFormat);
Graphics new_g = Graphics.FromImage(bitmap);
new_g.SmoothingMode =System.Drawing.Drawing2D.SmoothingMode.HighQuality;
new_g.InterpolationMode =System.Drawing.Drawing2D.InterpolationMode.HighQualityBicubic;
new_g.DrawImage(src_image, 0, 0, bitmap.Width, bitmap.Height);
src_image.Dispose();
bitmap.Save("C:\\Inetpub\\wwwroot\\ImageConverter\\bin\\resize.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
new_g.Dispose();
bitmap.Dispose();
}
catch(Exception e)
{
string a = e.Message;
}
}
Thanks
Gary
|
|
|
|
|
I have a couple of questions.- On what line, exactly, does the exception get thrown? Please step through your code in the debugger. I'm assuming it's
Graphics.DrawImage . - What is the pixel format of the image that you ran through the method?
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
The exception is being thrown on the bitmap.save method.
Thanks
Gary
|
|
|
|
|
What as the pixel format of the original image you passed through the method?
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
One other thing I noticed that, if "ImageConverter" is your ASP.NET project, you should not put files in the bin sub-directory. If ASP.NET is configured to handle the .jpg extension, then - by default - users will not be able to access bin\resize.jpg because access to files in the bin directory is disallowed by ASP.NET. You should consider saving the file to a directory users can access if you plan on passing it back as the src attribute of an IMG tag.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Hi,
I am trying to set the value of a DateTimePicker to the first of next month in a UK date format.
ie every day this month (March) the DTP will read 01/04/2005 then next month it will read 01/05/2004.
Anyone know how it can be done? I've sorted the month part out with AddMonth(1) but have no idea how to set the date to 01 each time?
Please can someone help?
Thanks in advance
Scott
|
|
|
|
|
Alright mate, not sure I understand your problem but hopefully the code below will help.
DateTime startOfMonth = DateTime.Now.AddMonths(1);
startOfMonth = startOfMonth.AddDays(-startOfMonth.Day + 1);
The code add's one month to the current date and then defaults the date to the 1st of the month.
|
|
|
|
|
Do keep in mind that the DateTime type always uses the Gregorian calendar, so you should use the Calendar class to truly get the right date if not doing this strickly for the DateTimePicker . See http://blogs.msdn.com/michkap/archive/2005/03/28/402839.aspx[^] for more information.
This posting is provided "AS IS" with no warranties, and confers no rights.
Software Design Engineer
Developer Division Sustained Engineering
Microsoft
[My Articles] [My Blog]
|
|
|
|
|
Thanks for replying folks, much appreciated.
The code works perfectly, thank you.
I will bear that in mind about the Gregorian Calendar too, thanks for pointing it out.
Again, much appreciated.
Scott
|
|
|
|
|
Hi all,
I was experimenting with generics and some new stuff of ASP.NET 2.0 in whidbey beta1 given during Teched 2004...everything was working fine till last night..and suddenly today morning when i opened beta1 horrible dialog box saying - "The beta period has expired- thank you for participating in our beta program, you can now safely remove Microsoft development environment from your computer" appeared...I have checked google and found that expiry date of whidbey beta1 is around 15th July 2005..so whats up???
The strange thing is - "It didnt show me any warning that my version is going to expire..." My colleagues are using the same version(teched beta1) but its fine for them...
So, Is there any way by which I can open that solution!!!!
Thanks in advance!!!
REgards
MaulikCE
i don want
|
|
|
|
|
Why not just use the Whidbey Beta 1 that's freely available on MSDN? You can download the express versions or have them mail you a DVD of the Enterprise version.
Tech, life, family, faith: Give me a visit.
I'm currently blogging about: He has a funny face. And he's my son.
Judah Himango
|
|
|
|
|
Check the date on your system. You system may be set to a date of future.
|
|
|
|
|
I want to duplicate a file.
However, exception occured when I use the Copy method twice.
e.g.
File.Copy("from1.jpg","to.jpg,true");
File.Copy("from2.jpg","to.jpg,true");
How can i solve it?
|
|
|
|
|