|
Please DON'T SHOUT!
however, how are you setting PageNumber? What is passing it around?
|
|
|
|
|
This guy has asked this and I have explained to him the many issues with his code. He's not changed any of it, I would say it's not worth talking to him, he obviously ignores people who try to help.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
Hi
I currently have a javascript function which is applied to a gridview:
GridView4.Attributes.Add("onkeydown", "return noCopyKey(event);");
how cann i apply this function to a whole page?
thanks
|
|
|
|
|
you can't magically do it, you need to add it to all the controls you want to use it.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
I wasnt hoping for magic I was hoping there was a line of code which you could add it to page rather then just one control at a time.
|
|
|
|
|
Sure - I don't think so.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
i managed by using the other persons response: put onkeydown="return noCopyKey(event) in body tag on masterpage managed to get it to work. Have to put javascript in the actual pages though not just in masterpage
cheerS!
|
|
|
|
|
How about...
onKeyPress event for body tag
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
the probably with that is the only body tag I have is in my masterpage, if I put the javascript there it doesnt work
|
|
|
|
|
Fixed, mispelt my function
cheers!
|
|
|
|
|
Hi all,
I have a windows service application that needs to make request to a remote web service (https:// ...) for uploading files. the contact mechanism between them is a SSL based channel.
I assigned my windows service to run under a specified user account and installed the client certificate with that user account as well.
And I am getting this exception as title, however, strange enough, I do not get this exception all the time, i got this exception sporadically. Does it prove that I did configure certificate properly? if so, what other reasons would cause this exception???
Any suggestion would be appriciated!!
Ming
|
|
|
|
|
I now have a problem with a piece of code which worked before!
My code to get an image object from a directory is:
System.Drawing.Image fullSizeImg = System.Drawing.Image.FromFile(imgFullPath);
Then I resize it as follows:
System.Drawing.Image thumbNailImg = fullSizeImg.GetThumbnailImage(newWidth, newHeight, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
In the debugger, fullSizeImg and thumbNailImg are {System.Drawing.Bitmap} so they must be ok. However, when I use the following code to save the image:
thumbNailImg.Save(fullPath);
I get the error message:
CS0103: The name 'thumbNailImg' does not exist in the current context
However, if I try and save the fullSizeImg (before resizing) this works fine, so I'm totally confused and desperate for help!
|
|
|
|
|
Forgive me if i'm incorrect in saying this but don't you need to create a NEW instance of the thumbNailImg first?
"Sex is not the answer, it's the question and the answer is yes"
|
|
|
|
|
I'm a newbie to all this (so please bear with me ) - I found the vb version of this code on the web and attempted to rewrite as C#. I thought I was creating a new instance in this line:
System.Drawing.Image thumbNailImg = fullSizeImg.GetThumbnailImage(newWidth, newHeight, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
If not, please tell me how.
Many thanks
Lorna
|
|
|
|
|
are they in the same method ?
|
|
|
|
|
Yes and I'm sure it was working yesterday although I have extended my code a bit
|
|
|
|
|
can you please give the exact code(do a copy paste)?
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
I am using populating a ListBox with the files I want to resize and when the user clicks a button, the method goProcessImages is called and I traverse through each one resizing it (well I'm trying to!). Thanks - here is my code behind (sorry it's a bit of a mess but I've been commenting out things to find out what's going wrong):
using System;
using System.Collections;
using System.Configuration;
using System.Drawing;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.IO;
public partial class ResizeImage : System.Web.UI.Page
{
ArrayList imageNames = new ArrayList();
string imagesDir = "D:\\Website\\BookImages\\";
//get path of Books dir in website
protected void Page_Load(object sender, EventArgs e)
{
string imgForLB = "";
if (!IsPostBack)
{
int i = 0;
try
{
foreach (string img in Directory.GetFiles(imagesDir, "*.jpg"))
{
imageNames.Add(img.Remove(0, 22));
}
foreach (string img in Directory.GetFiles(imagesDir, "*.jpeg"))
{
imageNames.Add(img.Remove(0, 22));
}
foreach (string img in Directory.GetFiles(imagesDir, "*.gif"))
{
imageNames.Add(img.Remove(0, 22));
}
}
catch
{
Response.Write("We are currently experiencing problems in obtaining images from the directory " +
imagesDir + "Make sure you are offline and this directory exists on your laptop and it is not empty.");
}
//write out image names to screen for Angell to check
for (i = 0; i < imageNames.Count; i++)
lbFileNames.Items.Add(imageNames[i].ToString());
}
}
// Required by GetThumbnailImage() method, but not used
public bool ThumbnailCallback()
{
return true;
}
protected void goProcessImages(object sender, EventArgs e)
{
string imageName = "";
//resize each file listed in listbox
foreach (ListItem item in lbFileNames.Items)
{
imageName = item.ToString();
if (imageName != "")
{
//createThumbnail(imageName, 400);
createThumbnail(imageName, 100);
}
}
}
protected void createThumbnail(string imgName, int newHeight)
{
string pathToFile = Server.MapPath("Images/Books/");
int origHeight = 0;
int origWidth = 0;
string thumbImgName = "";
string existsFilePath = "";
bool imageExists = false;
//get path of Books dir in website
string imgFullPath = "";
string fullPath = "";
//Once we have an instance of the Image class we can determine the height and width
//of the image by checking the Height and Width properties.
if (newHeight == 100)
thumbImgName = imgName.Replace(".", "-s.");
else
thumbImgName = imgName;
//path of image to retrieve (before resizing)
imgFullPath = imagesDir + imgName;
Response.Write("full path of image is " + imgFullPath);
//path of image to save (after resizing)
fullPath = pathToFile + thumbImgName;
//imgFullPath = imagesDir + imgName;
//try
//{
// create an image object, using the filename we just retrieved
System.Drawing.Image fullSizeImg = System.Drawing.Image.FromFile(imgFullPath);
//}
//catch
//{
//Response.Write("We are experiencing problems with the server at the moment.<br />" +
//"Please try again later.");
//}
//get orig height
origHeight = fullSizeImg.Height;
//get orig width
origWidth = fullSizeImg.Width;
float newWidthFloat = ((float)newHeight / (float)origHeight) * (float)origWidth;
int newWidth = Convert.ToInt32(newWidthFloat);
//check in case there is already an image with this name in website
existsFilePath = pathToFile + thumbImgName;
Response.Write(existsFilePath);
if (File.Exists(existsFilePath))
{
imageExists = true;
//need confirmation message
}
//if image height > the new target height, resize
//if (origHeight > newHeight)
//{
try
{
// create the actual thumbnail image
System.Drawing.Image thumbNailImg = fullSizeImg.GetThumbnailImage(newWidth, newHeight, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
}
catch
{
if (newHeight == 100)
{
Response.Write("We are experiencing problems with the server at the moment.<br />A thumbnail version of " + imgName + " has not been created. Please try again later.");
}
else
{
Response.Write("We are experiencing problems with the server at the moment.<br />" + imgName + " has not been resized. Please try again later.");
}
}
//try
//{
//save to website Books dir
//if (thumbNailImg != null)
thumbNailImg.Save(fullPath);
//}
//catch
//{
// Response.Write("We are experiencing problems with the server at the moment.<br />" + thumbImgName + " has not been saved to the website. Please try again later.");
//}
//Clean up / Dispose...
//thumbNailImg.Dispose();
//}
//else
//{
//try
//{
//save original image to website Books dir
//fullSizeImg.Save(fullPath);
//}
//catch
//{
//Response.Write("We are experiencing problems with the server at the moment.<br />" + thumbImgName + " has not been saved to the website. Please try again later.");
//}
//Clean up / Dispose...
//fullSizeImg.Dispose();
//}
}
}
|
|
|
|
|
Member 3402886 wrote: try
{
// create the actual thumbnail image
System.Drawing.Image thumbNailImg = fullSizeImg.GetThumbnailImage(newWidth, newHeight, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
}
Because of you are creating the variable inside try block, it is showing the error.
should be like this
System.Drawing.Image thumbNailImg;
try
{
thumbNailImg = fullSizeImg.GetThumbnailImage(newWidth, newHeight, new System.Drawing.Image.GetThumbnailImageAbort(ThumbnailCallback), IntPtr.Zero);
}
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
Thanks - tried that but get message:
CS0165: Use of unassigned local variable 'thumbNailImg'
on line:
thumbNailImg.Save(fullPath);
Thanks
Lorna
|
|
|
|
|
I dont think so,
Because GetThumbnailImage returns an Image object and thumbNailImg is also an Image object.
Am I right?
EVEN THE WORD IMPOSSIBLE SAYS I M POSSIBLE.
|
|
|
|
|
Member 3402886 wrote: CS0103: The name 'thumbNailImg' does not exist in the current context
Show your full code.
Member 3402886 wrote: fullSizeImg.GetThumbnailImage
Resizing image using GetThumbnailImage is inefficient and it returns only the thumbnail image attached to each image. So you will get pretty poorly resized image.
Create a Bitmap with the new size and width, load your image into a Graphics instance, use DrawImage() to draw image into the required size. Save the bitmap. You will get image resized without loosing quality.
|
|
|
|
|
HI
guys i am facing problem, in my application i am using data type decimal, when i get the value from data base and show in text box if the value is e.g. 99 it shows 99.00000 as i have specified 5 after precision in sql server, how can i convert the 99.00000 to 99 can any one let me know about it thankx in advance.
|
|
|
|
|
Convert.ToInt32(DecimalValue)
or
lblValue.Text = decimalValue.ToString("#,#0");
or
txtValueBox.Text = decimalValue.ToString("#,#0");
|
|
|
|
|
thansk for your answer but in case if there is 99.45 in database it converts it back to 99
in this case i want to show 99.4, kindly reply ASAP.
|
|
|
|