Showing posts with label changing. Show all posts
Showing posts with label changing. Show all posts

Monday, March 26, 2012

Trouble getting jpg to display in image control

Hi,

My company is changing its logo and I am having trouble getting my
existing image controls in asp.net apps to read the new jpg. I do not
need to programmatically change them, as they are static, but when
using the new jpegs I only get the little red x. I have added the new
jpg to the project, I can see it right there when I go to set the
image url of the control, and when I double click from the solution
explorer it displays properly in Photo Editor but no luck in my
control. Creating new controls and changing existing ones produces
the same result. I am able to use a new gif, but I am unhappy with
the image quality.

Any suggestions would be great.You'll want to make sure that the URL isn't pointing to your local file
system (file:) rather than a regular IIS url.

Also, is this inside the firewall? Are you using the same filename for the
new image?

Some intranets have very aggressive caching. You might defeat it by
changing the name of the .jpg if you haven't already tried that. Or ask the
security admin to dump the cache.

Just tossing out some ideas....

"Brian Hanson" <bdhanson@.mcdermott.com> wrote in message
news:169b400f.0312010828.2ad4bcb9@.posting.google.c om...
> Hi,
> My company is changing its logo and I am having trouble getting my
> existing image controls in asp.net apps to read the new jpg. I do not
> need to programmatically change them, as they are static, but when
> using the new jpegs I only get the little red x. I have added the new
> jpg to the project, I can see it right there when I go to set the
> image url of the control, and when I double click from the solution
> explorer it displays properly in Photo Editor but no luck in my
> control. Creating new controls and changing existing ones produces
> the same result. I am able to use a new gif, but I am unhappy with
> the image quality.
> Any suggestions would be great.

Saturday, March 24, 2012

Trouble updating

I have a Access database with 2 text fields. I'm reading one field into a text box, changing the value in the textbox and attempting to update the database with the new value. The page loads fine with the correct value in the textbox, but I'm getting a error on the Update statement. Below is the code. Any suggestions?

Sub LoadInventory()
Connect()
Dim strQuery As String = "SELECT Type, Number FROM Inventory WHERE type = 'squares'"

Dim dbComm As New OLEDBCommand(strQuery, objConnection)
Dim reader As OLEDBDataReader = dbComm.ExecuteReader()

reader.Read()
txtAmount.Text = reader.GetString(1)

reader.Close()
Disconnect()
End Sub

Sub btnChange_Click(ByVal Sender As Object, ByVal E As EventArgs)
UpdateInventory()
LoadInventory()
End Sub

Private Sub UpdateInventory()
Dim strSQL As String = "UPDATE Inventory SET Number = " & txtAmount.Text & " WHERE Type = 'squares'"
Connect()
Dim dbComm As New OLEDBCommand(strSQL, objConnection)
dbComm.ExecuteNonQuery()
Disconnect()
End Subinstead of

Dim strSQL As String = "UPDATE Inventory SET Number = " & txtAmount.Text & " WHERE Type = 'squares'"

try this
Dim strSQL As String = "UPDATE Inventory SET Number = " & Convert.ToInt32(txtAmount.Text) & " WHERE Type = 'squares'"

Jeff
Jeff,

Thanks for your reply. That however didn't work. Could it be the way I have my access database setup?

Jeremy
Jeff,

Does it work when you try putting in a static value for txtAmount.Text such as this:

"UPDATE Inventory SET Number =1 WHERE Type='squares'"

If it does work like that, then try doing this:


Try
Dim dbComm As New OLEDBCommand(strSQL, objConnection)
dbComm.ExecuteNonQuery()
Catch dbException As Exception
Response.Write(dbException.ToString())
End Try

Tell us what the exception is. Besides, it is always good practice anyway to put database queries inside a try statement - there are just way too many things that could go wrong to not catch those errors.

Aaron

Trouble with changing a value in a cookie.

I wanted to change a value in a existing cookie. I read the old value, modify it and to write the new value in the old cookie. Here is the code:

public bool SetCookie(string cookiename, string cookievalue, int iDaysToExpire) //create the cookie
{
try
{
HttpCookie objCookie = new HttpCookie(cookiename);
Response.Cookies.Clear();
Response.Cookies.Add(objCookie);
objCookie.Values.Add(cookiename, cookievalue); // adding the value to the cookie
DateTime dtExpiry = DateTime.Now.AddDays(iDaysToExpire); //expires
Response.Cookies[cookiename].Expires = dtExpiry;
}
catch (Exception e)
{
return false;
}
return true;
}

public string GetCookie(string cookiename)// method which gives the value from the cookie
{
string cookyval = "";
try
{
cookyval = Request.Cookies[cookiename].Value;
}
catch (Exception e)
{
cookyval = "";
}
return cookyval;
}

protected void Page_Load(object sender, EventArgs e)
{

String t, s,t1;
int i = 0;
s = "";
t = "";

t = GetCookie("test");//reading the cookie
//removing the name and getting the value
try
{
lbl1.Text = t; //
t1 = t.Remove(0, 9);
i = Int32.Parse(t1);
i = i + 1; //the value is modified
}
catch (Exception w) { lbl3.Text = "Convert isnt working."; }
s = Convert.ToString(i);

//writing the new value in the cookie
SetCookie("test", s, 1);

//testing to see if the new value is written
t1 = GetCookie("test");
lbl2.Text = s;
lbl3.Text = t1;
}
}What is your question, exactly? This code re-sets the cookie each time it runs. It seems to return exactly what you're setting it to ("test=0"). (Is that the value that you want it to have?)

Tuesday, March 13, 2012

Troubles displaying a changing read-only value

I am writing a form with one value being a total of a couple other values from my page. I put this in a read-only textbox so it can't be changed, and when I change the other boxes values, the JavaScript automatically changes this value. However, when I generate the e-mail I use textboxTotalSpace.text to make it appear in my email, but this will only display the original value, and not the new one.

Does anyone know how I fix this?

Thanks.

TextBox server control will not pick up the changed values (during LoadPostData()) if the textbox is set to read only. Check this link for a fix:

http://aspadvice.com/blogs/joteke/archive/2006/04/12/16409.aspx

Hope this helps,

Vivek


Thanks Vivek, but I am unsure where I am supposed to add theTextBox1.Attributes.Add("readonly","readonly")


That should go in the Page_Load event.

protected void Page_Load(object sender, EventArgs e)
{
// add the javascript attributes
TextBox1.Attributes.Add("readonly", "readonly");
}

Thanks


Because you are changing data at client side using java script....


You can put this in the Page Load method.


suresh modiya:

Because you are changing data at client side using java script....

Changed text box value client side WILL show up in the server code behind because textbox implements IPostBackDataHandler interface and it loads its value from the forms POST data in the LoadPostBackData() method.

Its only when it is set to readonly that this data load will not work on postback, hence the alternative.

Vivek