Image URL is not working [closed] - c#

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
I have this piece of coding which is supposed to receive a URL as a string and this URL is supposed to be set as the Image Url :-
Heres the code
foreach (SPListItem item in oSpListCln)
{
if (item.Title.Equals("Rubicks"))
{
Title.Text = item.Title;
lblSyp.Text = item["Sypnosis"].ToString();
PicPic.ImageUrl = item["PicPic"].ToString();
}
}
The value of item["PicPic"] is http://www.froot.nl/wp-content/uploads/quick-brown-fox-froot.jpg,http://www.froot.nl/wp-content/uploads/quick-brown-fox-froot.jpg
This doesn't work is it cause I'm setting a string as a URL of an image cause when I hard coded the link it worked but when I set the link to a string and try, it doesn't. Does anyone know a way of how to do this?

Given that the returned string is comma-separated as you wrote in comments, you could do something like:
string[] urlParts = item["PicPic"].ToString().Split(',');
PicPic.ImageUrl = urlParts[0];

Related

FileNotFound Exception but file is there [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
not much to explain as I have no logical explaination as to why this is not working :s
Just to confirm, It is a 'jpeg' file extention, the name is correct and I don't see any other issue with why it would not work be found.
You're saving it to a filename ending with "jpg" and then loading from a filename ending with "jpeg". Assuming you're trying to load the file you've just saved, that's the problem.
(I'd copy the code to point out the lines in question, but you only included it as an image...)
I'd strongly suggest constructing the filename once, and using that variable twice:
// I prefer using Path.Combine over string concatenation, but both will work.
// You might want to change "Identitys" to "Identities" though :)
string file = Path.Combine(#"C:\", "SimpleSkype", "Identitys", dd + ".jpg");
SaveSkypeAvatarToDisk(u.Handle, file);
using (Image image = Image.FromFile(file))
{
...
}

Add comma before last character of a string in c# [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 9 years ago.
I need to put a comma before the last char of a string.
For example:
Input: 101919 = Ouput: 10191,9
What is the best way to do that?
if (input.Length > 0) { input = input.Insert(input.Length - 1, ","); }
With the insert method
strTarget = strTarget.Insert( srtrTarget.Length -1, ",");

FormatNumber for c# [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
Im struggling to get the right syntax to use in c# for the vb function FormatNumber...i will say that 'iPremium' is an object as it returns data from a tableadapter.
the value that 'ipremium' holds is 943.4000 and the idea is to only have two decimal places after the '.', i would hope this is acheivable using the right syntax but unfortunately not being a c# expert, it could take a while to figure this out.
here's the vb code:
iPremium = FormatNumber(iPremium, 2, TriState.True)
any idea's on how this is acheivable?
thanks for any idea's and suggestions and excuse the ignorance if this is not worded correctly
var formattedNumber = iPremium.ToString("0.00");
or, if you wish to round the number, instead of just chopping-off precision:
var formattedNumber = Math.Round(iPremium, 2).ToString("0.00").Dump();
Here's a list of the various formats you can use with ToString: http://msdn.microsoft.com/en-us/library/dwhawy9k.aspx
var roundedNumber = Math.Round(iPremium, 2);
var formattedNumber = String.Format("{0:#.##}", roundedNumber);
I assume the TableAdapter returns a Datatable which can also be used strongly typed:
// first row as example (add using.System.Linq)
double value = table.AsEnumerable().First().Field<double>("iPremium");
Now you can use String.Format or just ToString with a custom format:
string result = value.ToString("0.00");

cannot implicitly convert type 'string' to 'system.collections.arraylist' in C# [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 10 years ago.
Here is my code :
XmlNodeList ProjectNode = DOC.GetElementsByTagName("AppBuilderProject");
foreach (XmlNode AllNodes in ProjectNode)
{
Project.Titel = AllNodes["Titel"].InnerText; // 1st value from node
foreach (XmlNode controlsform in Project.Forms) // arraylist Forms
{
Project.Forms = controlsform["forms"].InnerText;// error
}
}
Please tell me how to resolve this problem.
Property "Project.Forms" is obviously of type arraylist and property (XmlNode).InnerText is string
Try this
if(Project.Forms == null) Project.Forms = new ArrayList();
Project.Forms.Add(controlsform["forms"].InnerText);

NullRefererenceException [closed]

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.
Closed 11 years ago.
foreach (string line in assigment_lines)
{
// Object reference not set to an instance of
chars.AddRange(line.Split('=')); object.
}
string[] strArray = chars.ToArray();
My program give me Null Reference Exception in above code what a problem ?
Make sure that line is not null also check where do you define chars array.
You can do something like this:
foreach (string line in assigment_lines)
{
if (!string.IsNullOrEmpty(line)) {
chars.AddRange(line.Split('=')); // Object reference not set to an instance of object.
}
}
string[] strArray = chars.ToArray();

Categories

Resources