Salve, io ho un problema come dice il titolo.
Perchè ogni volta che invio e modifico un dato devo fare F5 dal browser per aggiornare quello che gli ho scritto dopo avere premuto il pulsante di modifica?.
il passaggio è cosi: http://localhost:82/admin/user/user_update.aspx?user=luigi
grazie, vi posto il codice:
user_update.aspx
user_update.aspx.cs
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.Odbc;
public partial class admin_user_user_update : System.Web.UI.Page
{
string ConnectionString = ConfigurationManager.AppSettings["DBConnectionString"];
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Popola();
}
}
private void Popola()
{
string str_name = Request.QueryString["user"];
string str_query = "SELECT * FROM user WHERE user_name='" + str_name + "'";
OdbcConnection conn = new OdbcConnection(ConnectionString);
OdbcCommand command = new OdbcCommand(str_query, conn);
command.Connection.Open();
OdbcDataReader reader = command.ExecuteReader();
while (reader.Read())
{
name.Text = "" + reader["user_name"] + "";
Firstname.Text = "" + reader["user_firstname"] + "";
sex.Text = "" + reader["user_sex"] + "";
birthday.Text = "" + reader["user_birthday"] + "";
username.Text = "" + reader["user_username"] + "";
password.Text = "" + reader["user_password"] + "";
email.Text = "" + reader["user_email"] + "";
skype.Text = "" + reader["user_skype"] + "";
msn.Text = "" + reader["user_msn"] + "";
other.Text = "" + reader["user_other"] + "";
photo.Text = "" + reader["user_photo"] + "";
city.Text = "" + reader["user_city"] + "";
cap.Text = "" + reader["user_cap"] + "";
address.Text = "" + reader["user_address"] + "";
telephone.Text = "" + reader["user_telephone"] + "";
info.Text = "" + reader["user_info"] + "";
suffering.Text = "" + reader["user_suffering"] + "";
hate.Text = "" + reader["user_hate"] + "";
friends.Text = "" + reader["user_friends"] + "";
}
command.Connection.Close();
}
protected void Button2_Click(object sender, EventArgs e)
{
//string str_id = Request.QueryString["id"];
string str_name = Request.QueryString["user"];
OdbcConnection conn = new OdbcConnection(ConnectionString);
string str_query = "UPDATE user SET user_name='" + name.Text + "',"
+ "user_firstname='" + Firstname.Text + "',"
+ "user_sex='" + sex.Text + "',"
+ "user_birthday='" + birthday.Text + "',"
+ "user_username='" + username.Text + "',"
+ "user_password='" + password.Text + "',"
+ "user_email='" + email.Text + "',"
+ "user_skype='" + skype.Text + "',"
+ "user_msn='" + msn.Text + "',"
+ "user_other='" + other.Text + "',"
+ "user_photo='" + photo.Text + "',"
+ "user_city='" + city.Text + "',"
+ "user_cap='" + cap.Text + "',"
+ "user_address='" + address.Text + "',"
+ "user_telephone='" + telephone.Text + "',"
+ "user_info='" + info.Text + "',"
+ "user_suffering='" + suffering.Text + "',"
+ "user_hate='" + hate.Text + "',"
+ "user_friends='" + friends.Text + "' WHERE user_name='" + str_name + "'";
OdbcCommand command = new OdbcCommand(str_query, conn);
command.Connection.Open();
command.ExecuteNonQuery();
Response.Write(str_query);
command.Connection.Close();
Response.Redirect("Default.aspx");
}
}
Mi sapete dire qual'è il problema?.
grazie mille!!