|
Good morning, most of my work is generally client server so some of the basic ASP.NET questions are a pain for me, so forgive me if this is stupid.
I am trying to load an image on the event of clicking a cell in a gridview. The gridview has a button and I am calling the RowCommand to load the picture. The field for the image name is in the gridview, the code looks like this (Basically)
protected void gvRecords_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "View")
{
Int32 rowIndex = Convert.ToInt32(e.CommandArgument.ToString());
string path = @"Images/Foo/images/";
string fileName = gvRecords.Rows[rowIndex].Cells[7].Text;
imgMyRecord.ImageUrl = Server.MapPath(path + fileName);
imgMyRecord.Height = 250;
imgMyRecord.Width = 250;
}
}
I have tried a static reference in the Mappath, but can't get the image to load. The possible caveat to this is that the "Images" folder referred to above is located on another server and is a virtual directory pointing to a UNC path. So I added the Virtual folder in the app folder pointing to \\server\folder.
Where is my issue? Is the setup of the virtual folder wrong or am I just plain old doing it wrong? Or both?
|
|
|
|
|
Examine the HTML source of your page and see exactly what ImageUrl is being created, debug from there.
|
|
|
|
|
Hi,I m having a menubar with 7 menu,designed with css. problem is when form loads first time,3 menu get shifted in 2nd row. but when i refresh page, all 7 menu display in one row which is right.
can anybody guess what is the problem?
|
|
|
|
|
Spurple wrote: can anybody guess what is the problem?
I guess your css is not applying properly. Did you tested with all browser ?
If you are using FF, then install FireBug and test the CSS and all tags, or Copy the View Source of pages first time and then compare with second html code.
You will get to know the cause.
Thanks
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
I am using below code to encrypt and decrypt querystring value .it works fine
but it show nullrefrence exception when
some works not performed in mysite for more than 15-20 minute.
it shows savedKey and savedIV must be non-null." error
I am not analyzing why this error occur .
private static byte[] savedKey = null;
private static byte[] savedIV = null;
public static byte[] key
{
get { return savedKey; }
set { savedKey = value; }
}
public static byte[] IV
{
get { return savedIV; }
set { savedIV = value; }
}
private static void rdGenerateSecretKey(RijndaelManaged rdProvider)
{
if (savedKey == null)
{
rdProvider.KeySize = 256;
rdProvider.GenerateKey();
savedKey = rdProvider.Key;
}
}
private static void rdGenerateSecreInitVector(RijndaelManaged rdProvider)
{
if (savedIV == null)
{
rdProvider.GenerateIV();
savedIV = rdProvider.IV;
}
}
public static string Encrypt(string originalStr)
{
Random RandNum = new Random();
int RandomNumber = RandNum.Next(1000000, 9999999);
originalStr = String.Format("{0}&Random={1}", originalStr, RandomNumber.ToString());
//encode data string to be stored in memory
byte[] originalStrAsBytes = Encoding.ASCII.GetBytes(originalStr);
byte[] originalBytes = { };
// create memory stream to contain output.
using (MemoryStream memStream = new MemoryStream(originalStrAsBytes.Length))
{
using (RijndaelManaged rijndel = new RijndaelManaged())
{
// generate secret ket and save in to vector.
rdGenerateSecretKey(rijndel);
rdGenerateSecreInitVector(rijndel);
if (savedKey == null || savedIV == null)
{
throw (new NullReferenceException("savedKey and savedIV must be non-null."));
}
// Create Encrypt and Stream Objects.
using (ICryptoTransform rdTransform=rijndel.CreateEncryptor((byte[]) savedKey.Clone(),(byte[]) savedIV.Clone()))
{
using (CryptoStream cryptostream =new CryptoStream(memStream,rdTransform,CryptoStreamMode.Write))
{
// write crypto stream data in memeory stream
cryptostream.Write(originalStrAsBytes,0,originalStrAsBytes.Length);
cryptostream.FlushFinalBlock();
originalBytes=memStream.ToArray();
}
}
}
}
// convert encrypted string
string encryptedStr=Convert.ToBase64String(originalBytes);
return(encryptedStr);
}
public static string Decrypt(string encryptedStr)
{
// unconvert encrypted string.
encryptedStr = encryptedStr.Replace(" ", "+");
byte[] encryptedAsBytes = Convert.FromBase64String(encryptedStr);
byte[] intialText = new byte[encryptedAsBytes.Length];
using (RijndaelManaged rijndael = new RijndaelManaged())
{
using (MemoryStream memStream = new MemoryStream(encryptedAsBytes))
{
if (savedKey == null || savedIV == null)
{
throw (new NullReferenceException("savedKey and savedIV must be non-null. "));
}
// Create Decrypt and Stream Objects.
using (ICryptoTransform rdTransform = rijndael.CreateDecryptor((byte[])savedKey.Clone(), (byte[])savedIV.Clone()))
{
using (CryptoStream cryptostream = new CryptoStream(memStream, rdTransform, CryptoStreamMode.Read))
{
// Read decryte string as bytes
cryptostream.Read(intialText, 0, intialText.Length);
}
}
}
// convert byte[] to string
string decryptedStr = Encoding.ASCII.GetString(intialText);
return (decryptedStr);
}
}
public static System.Collections.Hashtable FillQs(HttpRequest request)
{
char[] SepMain = { '&' };
char[] SepSub = { '=' };
string Test = string.Empty;
System.Collections.Hashtable hasTableQueryStringId = new System.Collections.Hashtable();
if (request.QueryString["Q"] != null)
{
string[] Param = Decrypt(request.QueryString["Q"].ToString()).Split(SepMain, StringSplitOptions.RemoveEmptyEntries);
foreach (string str in Param)
{
string[] ParamKey = str.Split(SepSub);
//request.QueryString.Set(request.QueryString[ParamKey[0].ToString()], ParamKey[1].ToString());
//request.QueryString[ParamKey[0].ToString()] = ParamKey[1].ToString();
hasTableQueryStringId.Add(ParamKey[0].ToString(), ParamKey[1].ToString());
}
}
else
{
hasTableQueryStringId.Add("NoAttachments", "NoAttachments");
}
return hasTableQueryStringId;
}
|
|
|
|
|
I would say this sounds like a session timeout.
Try to set a shorter time of period per session in web.config and try to confirm my suggestion.
Greetings
Covean
|
|
|
|
|
Hello, On my local Dev machine I have developed a .net 3.5 (c#) web project (File System) and created the sql server 2005 objects i.e. tables. stored procedures, etc. All works fine. I have copied the database onto the Dev sql server. Now I would like to place the web site onto the dev server. Where do I start and what needs doing. Notice that I have developed the project using File System.
In addition, note that the .sln file is not present in the folder where I have the .cs and .aspx files.
Thanks
|
|
|
|
|
arkiboys wrote: Now I would like to place the web site onto the dev server.
Are you talking about to deploy the web site on IIS Server ? or want to run in Dev Server in VS IDE ?
Please let me know. I will help you out.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Hi,
i am using asp.net 2.0...
i want to convert word to pdf without install any software.
plz give valuable solution for me...
Yours,
KaNNaN
-----------------------------------------------------------------
"Success is When Ur Signature Becomes An Autograph"
|
|
|
|
|
|
|
Hi,
please send some other example...
Yours,
KaNNaN
-----------------------------------------------------------------
"Success is When Ur Signature Becomes An Autograph"
|
|
|
|
|
Hi To All,
I am having a requirement to get the database values into an array list using javascript.
Can any one suggest me
sai krishna
|
|
|
|
|
Using JavaScript alone? You can't. Use Ajax or scriptable web service to access the database from your JavaScript
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
Hello all,
I am developing a site using ASP.NET 3.5 using the default (English) language. I have a drop down button somewhere on the page which has two options English and Arabic with a lable that says Select a language you wish to view this site with.
Please how do I make this functional (i.e to change the site content to the selected Language)?
Thank you all for your usual assistance.
|
|
|
|
|
This is called localization. You need to use Localization features of ASP.NET.
Here is few startup article for you.
An Easy Introduction to Localization in ASP.NET 2.0[^]Ref 2[^]
You will find many more in google.
Let me know if you have any issue.
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
Thank you Abhijit,
After I am through with the links you give me, I will let u know my next step...
Thanks
|
|
|
|
|
Sure. Let me know if you have any issue with this. I am here to help and learn
Abhijit Jana | Codeproject MVP
Web Site : abhijitjana.net
Don't forget to click "Good Answer" on the post(s) that helped you.
|
|
|
|
|
I have a question about defining a foreign key relationship on the same table.
will cascade property work on the table.
Thanks and regards,
Amit Patel
|
|
|
|
|
Hi Amit,
To create a Foreign Key, you must have a corresponding Primary Key in another table else not on the same table. The cascade on update option (if turned on/selected) automatically updates the foreign key as soon as you change it's primary key in the primary table.
Are you clear with this explanation? If yes, don't forget to mark it as a Good Answer.
Happy programming!
|
|
|
|
|
We can create primary and foreign key relation in same table that is what i already tried but on delete cascade property is not working.
Thanks and regards,
Amit PAtel
|
|
|
|
|
First of all, which database do you use?
They all handle such foreign keys (they are called self-referential) indifferent ways.
|
|
|
|
|
I am populating a check list box from the database as follows:
for (int i = 0; i < intClassID; i++)
{
strClassID = dtClass.Rows[i]["ClassID"].ToString();
strName = dtClass.Rows[i]["Name"].ToString();
chklstClass.Items.Add(new ListItem(strName, strClassID));
}
So each item in the listbox has an ID
Now I would like to retrieve so that the IDs are selected approprioately. This is what I do:
for (int i = 0; i <= dtClass.Rows.Count - 1; i++)
{
int intClassID = int.Parse(dtClass.Rows[i][0].ToString());
chklstClass.Items[intClassID].Selected = true;
}
It does not seem to get the proper ID's
What am I doing wrong?
is this to do with SetItemChecked(i, true) ?
Thanks
|
|
|
|
|
arkiboys wrote: chklstClass.Items[intClassID].Selected = true;
You are trying to use the ClassID as the index to the items collection.
I know the language. I've read a book. - _Madmatt
|
|
|
|