|
iwant to disable image button.
if (this.PageNumber == 1 )
{
ImageButton1.Enabled = false;
}
else
{
ImageButton1.Enabled = true; ;
}
THIS IS NOT DISABLING THE IMAGEBUTTON.
|
|
|
|
|
God.
WHERE DO YOU CALL THIS CODE ? IN WHAT METHOD ?
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.
|
|
|
|
|
iam having the 1 to 11 pages .
Previous and Next image buttons .
If iam in First Page PREVIOUS IMAGE BUTTON should be disable.
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
if (this.PageNumber == 1)
{
Response.Redirect("pge1.aspx");
ImageButton1.Enabled = false;
ImageButton2.Enabled = true;
}
else
{
this.PageNumber -= 1;
Response.Redirect("pge" + this.PageNumber.ToString() + ".aspx");
}
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
if (this.PageNumber == 11)
{
//ImageButton1.Enabled = true;
//ImageButton2.Enabled = false;
//lnkNext.Enabled = false;
Response.Redirect("pge11.aspx");
}
else
{
ImageButton1.Enabled = true;
this.PageNumber += 1;
Response.Redirect("pge" + this.PageNumber.ToString() + ".aspx");
}
}
|
|
|
|
|
Oh, you're the guy from the other day. I see your code is still a disaster. You still have the same issue you had the other day. Refer to my answers from then, no point in repeating them if you're going to ignore me.
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 don't know what's more depressing, that you'd sit on such a trivial problem for days ( and I assume you're just going to ask it again ), that you'd ignore the advice you're given and just stop posting when someone reminds you that you have a solution, or that someone is paying you to sit idly by because you can't work out how to solve a simple problem when you've been given a clear solution.
Do some research on what response.redirect does. Or, just think about it for a minute.
Christian Graus
No longer a Microsoft MVP, but still happy to answer your questions.
|
|
|
|
|
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
|
|
|
|