hey guys i am making an art website for my fiance but cant get the images to display and i am doing it exactly like in previews websites i made but using visual studio 2012 from 2008. Here is the code. I get the error sign in the image and not the correct image. It loads the path from the database witch is Art/1.jpg.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class Home : System.Web.UI.Page
{
int Add = 1;
protected void Page_Init(object sender, EventArgs e)
{
Database s = new Database();
int Total = s.ArtCount(); //Count the total of cars int the database
for (int loop = Total; loop > 0; loop--)
{
Panel Panel1 = new Panel(); //Create a new panel for all the cars
Panel1.ID = "pnl" + loop.ToString();
Panel1.Style["position"] = "absolute";
Panel1.Style["left"] = "155px";
Panel1.Style["top"] = "400px";
Panel1.Style["Height"] = "200px";
Panel1.Style["Width"] = "1000px";
Panel1.BackColor = System.Drawing.Color.Black;
form1.Controls.Add(Panel1);
if (Add >= 2)
{
int Top = (400 * (Add - 1));
Panel1.Style["top"] = (250 + Top + 20).ToString() + "px"; //Set the second and more panels down
}
Add++;
string Art = s.LoadArt(loop);
string ArtID = Art.Substring(0, Art.IndexOf("|"));
Art = Art.Substring(ArtID.Length + 1);
string ArtName = Art.Substring(0, Art.IndexOf("|"));
Art = Art.Substring(ArtName.Length + 1);
string Description = Art.Substring(0, Art.IndexOf("|"));
Art = Art.Substring(Description.Length + 1);
string PicUrl = Art.Substring(0, Art.IndexOf("|"));
string path = Server.MapPath(PicUrl);
Image image1 = new Image();
image1.ID = "img" + ArtID +loop;
image1.ImageAlign = ImageAlign.AbsMiddle;
image1.Visible = true;
image1.ImageUrl = path;
image1.Style["Left"] = "10px";
image1.Style["position"] = "absolute";
image1.Style["top"] = "10px";
image1.Height = 180;
image1.Width = 230;
Panel1.Controls.Add(image1);
Label label1 = new Label(); //Create a label for the description of each car
label1.ID = "lblDescription" + ArtID;
label1.Text = Description;
label1.ForeColor = System.Drawing.Color.Lime;
label1.BorderStyle = BorderStyle.Groove;
label1.BorderColor = System.Drawing.Color.Violet;
label1.Style["Left"] = "500px";
label1.Style["position"] = "absolute";
label1.Style["top"] = "30px";
Panel1.Controls.Add(label1);
string View = s.TimesView(ArtID);
Label label10 = new Label(); //Create a label for the times each car is viewed
label10.ID = "lblView" + ArtID+loop;
label10.Text = "Times Viewed: " + View;
label10.ForeColor = System.Drawing.Color.Lime;
label10.Style["Left"] = "799px";
label10.Style["position"] = "absolute";
label10.Style["top"] = "170px";
Panel1.Controls.Add(label10);
Button btnView = new Button(); //Create a button to view a car for all cars
btnView.ID = ArtID;
btnView.Text = "View";
btnView.ForeColor = System.Drawing.Color.DeepSkyBlue;
btnView.BackColor = System.Drawing.Color.Gray;
btnView.BorderColor = System.Drawing.Color.Violet;
btnView.Style["top"] = "150px";
btnView.Style["left"] = "800px";
btnView.Style["Height"] = "20px";
btnView.Style["position"] = "absolute";
btnView.BorderStyle = BorderStyle.Outset;
btnView.Command += new CommandEventHandler(btnView_Command); //Create a command EventHandler to now what button was clicked
btnView.CommandArgument = ArtID; //Set the commandArguments = to the carID
Panel1.Controls.Add(btnView);
}
}
void btnView_Command(object sender, CommandEventArgs e)
{
string ArtID = e.CommandArgument.ToString(); //Gets theCarId from the CommandArgument
Session["ArtID"] = ArtID; //Create session CarID and set it = to the CarID
Response.Redirect("ViewArt.aspx"); //Redirect to the ViewCar page
}
}
Related
Ok, so i have written code to make a PDF file using Itextsharp and variables from a select statement. and updates into a database. the reader has to return multiple results with the query that i have made. for some reason it stops after the first result.
can anyone tell me what i need to change to make it iterate through each row that has been returned and update it to the database within in the while loop.
here is my code.
public Form1()
{
InitializeComponent();
}
private void CreateBtn_Click(object sender, EventArgs e)
{
try
{
make_pdf();
MessageBox.Show("completed");
}
catch (Exception exe )
{
MessageBox.Show("failed");
}
}
public void vaiabless()
{
}
public static void make_pdf()
{
string Contact = "";
string emailAddress = "";
string Tel = "";
string InvoiceDate = "";
string address = "";
string Reference = "";
string AccountNo = "";
string Debit = "";
string Credit = "";
string refnum = "";
string transtype = "";
string breaker = "|";
string connetionString = null;
MySqlConnection cnn;
connetionString = "*************";
cnn = new MySqlConnection(connetionString);
try
{
cnn.Open();
// MessageBox.Show("Connection Open ! ");
}
catch (Exception ex)
{
MessageBox.Show("Can not open connection ! ");
}
try
{
MySqlDataReader reader = null;
string selectCmd = "SELECT accounting.code,users.curr_email , users.physicaddr ,accounting.date , accounting.refnum , accounting.transtype, users.telephone , accounting.debit , accounting.acc_pdf, accounting.credit, accounting.reference, users.contact, accounting.transnum FROM accounting INNER JOIN users ON accounting.code = users.code WHERE(accounting.transtype = 1)";
MySqlCommand createcommand = new MySqlCommand(selectCmd, cnn);
reader = createcommand.ExecuteReader();
while (reader.Read())
{
if (reader.HasRows)
{
//get account number
AccountNo = reader["code"].ToString();
//get emailaddress
emailAddress = reader["curr_email"].ToString();
transtype = reader["transtype"].ToString();
//get Contact Name
Contact = reader["contact"].ToString();
//get telephone number
Tel = reader["telephone"].ToString();
//Get Date
InvoiceDate = reader["date"].ToString();
//Get reference
Reference = reader["reference"].ToString();
//Get Address
address = reader["physicaddr"].ToString();
//Get Debit
Debit = reader["debit"].ToString();
//Get Credit
Credit = reader["credit"].ToString();
//Get Refnum
refnum = reader["refnum"].ToString();
MemoryStream ms = new MemoryStream();
byte[] bits = new byte[0];
// Make The PDF File
Document NewDoc = new Document(iTextSharp.text.PageSize.A4, 0, 0, 0, 0);
PdfWriter pdfwri = PdfWriter.GetInstance(NewDoc,ms);
NewDoc.Open();
iTextSharp.text.Image img = iTextSharp.text.Image.GetInstance("intsa-header.jpg");
img.ScaleAbsolute(596f, 100f);
//Account List
List AccountNolist = new List(List.UNORDERED);
AccountNolist.SetListSymbol("");
AccountNolist.IndentationLeft = 300f;
AccountNolist.Add(new ListItem("AccountNo " + AccountNo));
// AddressList
List AddressList = new List(List.UNORDERED);
AddressList.SetListSymbol("");
AddressList.IndentationLeft = 300f;
AddressList.Add(new ListItem("Address: " + address));
#region Emailaddresslist
//EmailAddressList
List emailAddresslist = new List(List.UNORDERED);
emailAddresslist.SetListSymbol("");
emailAddresslist.IndentationLeft = 300f;
emailAddresslist.Add(new ListItem("Email address: " + emailAddress));
#endregion
//ContactList
List Contactlist = new List(List.UNORDERED);
Contactlist.SetListSymbol("");
Contactlist.IndentationLeft = 300f;
Contactlist.Add(new ListItem("Contact: " + Contact));
//TelephoneList
List Telephonelist = new List(List.UNORDERED);
Telephonelist.SetListSymbol("");
Telephonelist.IndentationLeft = 300f;
Telephonelist.Add(new ListItem("Tel: " + Tel));
// Make a Table
#region pdftable
//PdfPTable General_Table = new PdfPTable(1);
//General_Table.SpacingBefore = 50f;
//General_Table.SpacingAfter = 50f;
//PdfPCell Caption = new PdfPCell(new Phrase("Description"));
//PdfPCell Body = new PdfPCell(new Phrase(" " + refnum + " "+ Reference + " Total Due: " + Debit ));
//Body.HorizontalAlignment = Element.ALIGN_RIGHT;
//Caption.Colspan = 0;
//Caption.HorizontalAlignment = 1;
//General_Table.AddCell(Caption);
//General_Table.AddCell(Body);
PdfPTable mytable = new PdfPTable(3);
mytable.SpacingBefore = 40f;
Paragraph accountpar = new Paragraph("Description");
accountpar.IndentationLeft = 200f;
accountpar.SpacingBefore = 30f;
accountpar.SpacingAfter = 10f;
Paragraph Referencepar = new Paragraph( Reference);
Referencepar.IndentationLeft = 200f;
Referencepar.SpacingBefore = 30f;
Referencepar.SpacingAfter = 10f;
Paragraph Totalpar = new Paragraph("Total Due:" + "R" + Debit);
Totalpar.IndentationLeft = 200f;
Totalpar.SpacingBefore = 30f;
Totalpar.SpacingAfter = 10f;
Paragraph Refnumpar = new Paragraph("Reference Num: "+refnum);
Refnumpar.IndentationLeft = 150f;
Refnumpar.SpacingBefore = 10f;
Refnumpar.SpacingAfter = 30f;
mytable.AddCell(Refnumpar);
mytable.AddCell(Referencepar);
mytable.AddCell(Totalpar);
#endregion
//add Image to pdf
NewDoc.Add(img);
//add accountNo to pdf
NewDoc.Add(AccountNolist);
//add Contact to pdf
NewDoc.Add(Contactlist);
//add emailaddress to pdf
NewDoc.Add(emailAddresslist);
//add Telephone Number to pdf
NewDoc.Add(Telephonelist);
//add address to pdf
NewDoc.Add(AddressList);
//NewDoc.Add(accountpar);
//NewDoc.Add(Supscriptionpar);
NewDoc.Add(mytable);
//save Pdf
NewDoc.Close();
bits = ms.ToArray();
string updateCmd = "UPDATE users.accounting SET acc_pdf = #acc_pdf WHERE refnum =" + refnum;
MySqlConnection cnnx;
connetionString = "****************";
cnnx = new MySqlConnection(connetionString);
MySqlCommand Updatecommand = new MySqlCommand(updateCmd, cnnx);
Updatecommand.Parameters.AddWithValue("#acc_pdf", bits);
cnnx.Open();
Updatecommand.ExecuteNonQuery();
cnnx.Close();
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
private void Form1_Load(object sender, EventArgs e)
{
}
}
}
Try to change the order of your statements like given on msdn's example for the MySqlDataReader:
if (reader.HasRows)
{
while (reader.Read())
{
Console.WriteLine("{0}\t{1}", reader.GetInt32(0),
reader.GetString(1));
}
}
else
{
Console.WriteLine("No rows found.");
}
Also check what #Cameron Tinker asked:
Does the query return more than one result if you run it on the
database directly?
And to avoid resource leaks, don't forget to close the reader with reader.Close(); and also the connections. (or better use the using keyword)
Hi given below code sets focus on last image in my panel.
how do i set it to focus on first image?
I sort of understand i have to use ID of image button i create on fly. but don't know how.Please help.
var fileIdx = 0;
foreach (Tripclass Trip in TripsByTripIds )
{
fileIdx++;
ImageButton imageButton = new ImageButton(){ ID = "imageBtn" + fileIdx };
imageButton.ImageUrl = "~/" +Trip.CorridorName+"/"+Trip.Time+"/"+Trip.ImgFileName;
imageButton.Height = Unit.Pixel(100);
imageButton.Style.Add("padding", "5px");
imageButton.Width = Unit.Pixel(100);
imageButton.Click += new ImageClickEventHandler(imageButton_Click);
AMSPanel1.Controls.Add(imageButton);
AMSPanel1.Height = Unit.Pixel(860);
imageButton.Focus();
}
var fileIdx = 0;
foreach (Tripclass Trip in TripsByTripIds )
{
fileIdx++;
ImageButton imageButton = new ImageButton(){ ID = "imageBtn" + fileIdx };
imageButton.ImageUrl = "~/" +Trip.CorridorName+"/"+Trip.Time+"/"+Trip.ImgFileName;
imageButton.Height = Unit.Pixel(100);
imageButton.Style.Add("padding", "5px");
imageButton.Width = Unit.Pixel(100);
imageButton.Click += new ImageClickEventHandler(imageButton_Click);
AMSPanel1.Controls.Add(imageButton);
AMSPanel1.Height = Unit.Pixel(860);
if(fileIdx == 1)
{
imageButton.Focus();
}
}
The only thing changed is this:
From:
imageButton.Focus();
To:
if(fileIdx == 1)
{
imageButton.Focus();
}
In my ASP.Net page I need to show an HTML div who contains : Images, Text, Arrows and Connectors.
What are my "Connectors" ?
It's an ImageButton, and when the user click on this connector, the HTML div is showing a new content. This connectors are used to navigate in a TreeView.
But my problem is :
I create all my connectors (and all the HTML div content) dynamically. When the user click on the first connector the HTML div is showing new content. But on this second content, when the user click on a connector : nothing. The Click event of the ImageButton is not fired.
This is my Connector creation (on PageLoad and then on each Connector Click) :
List<Connecteur> ListConnecteur = new List<Connecteur>();
ListConnecteur = NomenclatureObj.SelectConnecteurs(DocId, ExterneData.RapidoBDDCnx);
foreach (Connecteur CeConnecteur in ListConnecteur)
{
if (CeConnecteur.FK_docversion_suivant_id != 0)
{
ImageButton ImgBtnTmp = new ImageButton();
ImgBtnTmp.Width = 30;
ImgBtnTmp.Height = 30;
ImgBtnTmp.ImageUrl = "~/images/GreenButton.png";
ImgBtnTmp.Style.Add("left", CeConnecteur.position_x_pix.ToString() + "px");
ImgBtnTmp.Style.Add("top", CeConnecteur.position_y_pix.ToString() + "px");
ImgBtnTmp.Click += new ImageClickEventHandler(ImgBtnTmp_Click);
ImgBtnTmp.CommandArgument = CeConnecteur.FK_docversion_suivant_id.ToString();
ImgBtnTmp.Style.Add("position", "absolute");
DivAffichage.Controls.Add(ImgBtnTmp);
ImgBtnTmp.CausesValidation = true;
}
}
And this is my Connector OnClick :
public void ImgBtnTmp_Click(object sender, EventArgs e)
{
ImageButton ThisBtn = sender as ImageButton;
string CommandArg = ThisBtn.CommandArgument;
int DocId = Convert.ToInt32(CommandArg);
TREEVIEW_NIVEAU++;
//DocId of the clicked connector
Session["DocId"] = DocId;
ClearDiv();
LoadDiv(DocId);
}
EDIT 1 : My whole LoadDiv() function
public void LoadDiv(int DocId)
{
#region Connecteurs
List<Connecteur> ListConnecteur = new List<Connecteur>();
ListConnecteur = NomenclatureObj.SelectConnecteurs(DocId, ExterneData.RapidoBDDCnx);
foreach (Connecteur CeConnecteur in ListConnecteur)
{
if (CeConnecteur.FK_docversion_suivant_id != 0)
{
ImageButton ImgBtnTmp = new ImageButton();
ImgBtnTmp.Width = 30;
ImgBtnTmp.Height = 30;
ImgBtnTmp.ImageUrl = "~/images/GreenButton.png";
ImgBtnTmp.Style.Add("left", CeConnecteur.position_x_pix.ToString() + "px");
ImgBtnTmp.Style.Add("top", CeConnecteur.position_y_pix.ToString() + "px");
ImgBtnTmp.Click += new ImageClickEventHandler(ImgBtnTmp_Click);
ImgBtnTmp.CommandArgument = CeConnecteur.FK_docversion_suivant_id.ToString();
ImgBtnTmp.Style.Add("position", "absolute");
DivAffichage.Controls.Add(ImgBtnTmp);
}
}
#endregion
#region Textes
List<Texte> ListTexte = new List<Texte>();
ListTexte = NomenclatureObj.SelectTextes(DocId, LANGUE_ID, ExterneData.RapidoBDDCnx);
foreach (Texte CeTexte in ListTexte)
{
Label LblText = new Label();
LblText.Text = CeTexte.contenu;
LblText.Width = CeTexte.largeur_voulue_pix;
LblText.Style.Add("left", CeTexte.position_x_pix.ToString() + "px");
LblText.Style.Add("top", CeTexte.position_y_pix.ToString() + "px");
LblText.Style.Add("position", "absolute");
DivAffichage.Controls.Add(LblText);
}
#endregion
#region Images
List<ImageNomenclature> ListImg = new List<ImageNomenclature>();
ListImg = NomenclatureObj.SelectImages(DocId, ExterneData.RapidoBDDCnx);
foreach (ImageNomenclature CetteImage in ListImg)
{
Image ImgTmp = new Image();
ImgTmp.ImageUrl = "~/Nomenclature/RAPIDO/planches/" + CetteImage.fichier_chemin;
ImgTmp.Width = CetteImage.largeur_voulue_pix;
ImgTmp.Height = CetteImage.hauteur_voulue_pix;
ImgTmp.Style.Add("left", CetteImage.position_x_pix.ToString() + "px");
ImgTmp.Style.Add("top", CetteImage.position_y_pix.ToString() + "px");
ImgTmp.Style.Add("position", "absolute");
ImgTmp.Style.Add("z-index", "-1");
DivAffichage.Controls.Add(ImgTmp);
}
#endregion
#region Flèches
List<Fleche> ListFleche = new List<Fleche>();
ListFleche = NomenclatureObj.SelectFleches(DocId, LANGUE_ID, ExterneData.RapidoBDDCnx);
foreach (Fleche CetteFleche in ListFleche)
{
string HTMLCode = "<svg xmlns=\"http://www.w3.org/2000/svg\" width=\"800\" height=\"600\"><line x1=\"" + CetteFleche.position_x1_pix + "\" y1=\"" + CetteFleche.position_y1_pix + "\" x2=\"" + CetteFleche.position_x2_pix + "\" y2=\"" + CetteFleche.position_y2_pix + "\" stroke=\"#ff0000\"/></svg>";
//DivAffichage.InnerHtml += HTMLCode;
}
#endregion
}
You should create your dynamic control every time on Page_Init or Page_Load if you would like to handle events from them after Postback.
See links below for details:
http://msdn.microsoft.com/en-us/library/y3bwdsh3%28v=vs.140%29.aspx
http://msdn.microsoft.com/en-us/library/hbdfdyh7%28v=vs.100%29.aspx
Here you can see the same problem.
EDIT
Try to do something like this:
protected void Page_Load(object sender, EventArgs e)
{
if (IsPostBack)
{
LoadDiv(Session["DocId"])
}
}
i'm in a trouble!
I'm generating a lot of gridviews dinamically, with dinamic values to columns.
The columns are ever the same.
I want to know how can i set the size of this columns.
That's my code, with my effort.
private void generateControls( List<List<DataRow>> grids)
{
DataTable dt = new DataTable();
int i = 0;
foreach (List<DataRow> lst in grids)
{
dt = lst.CopyToDataTable();
GridView grv = new GridView();
grv.AlternatingRowStyle.BackColor = System.Drawing.Color.FromName("#cccccc");
grv.HeaderStyle.BackColor = System.Drawing.Color.Gray;
grv.Width = new Unit("100%");
//grv.RowStyle.Wrap = false;
grv.RowStyle.Width = new Unit("100%");
grv.ID = "grid_view" + i;
grv.DataSource = dt;
grv.DataBind();
/* grv.Columns[0].ItemStyle.Width = new Unit("5%");
grv.Columns[1].ItemStyle.Width = new Unit("7%");
grv.Columns[2].ItemStyle.Width = new Unit("12%");
grv.Columns[3].ItemStyle.Width = new Unit("12%");
grv.Columns[4].ItemStyle.Width = new Unit("7%");
grv.Columns[5].ItemStyle.Width = new Unit("7%");
grv.Columns[6].ItemStyle.Width = new Unit("23%");
grv.Columns[7].ItemStyle.Width = new Unit("22%");
grv.Columns[8].ItemStyle.Width = new Unit("5%");*/
Label lblBlankLines = new Label();
lblBlankLines.Text = "<br />";
Panel panelGrid = new Panel();
panelGrid.ID = "panel_grid" + i;
Label lblTipo = new Label();
string tipoOcorrencia = lst[0]["Ocorrência"].ToString();
/*
* Capitalized
* TextInfo myTI = new CultureInfo("pt-BR", false).TextInfo;
string novoTipoOcorrencia = myTI.ToTitleCase(tipoOcorrencia);*/
int quantidade = lst.Count;
lblTipo.Text = " - " + tipoOcorrencia + ": " + quantidade;
LinkButton lkBtn = new LinkButton();
lkBtn.ID = "link_button" + i;
lkBtn.Text = "Exibir | Ocultar";
lkBtn.Attributes["onClick"] = "javascript:return ocultaGrid('" + panelGrid.ID + "'), false";
panel_status.Controls.Add(lblBlankLines);
panel_status.Controls.Add(lkBtn);
panel_status.Controls.Add(lblTipo);
panelGrid.Controls.Add(grv);
panel_status.Controls.Add(panelGrid);
panel_status.DataBind();
i++;
}
}
I've tried to get the columns, but i got an error, telling me an invalid index access.
How can i access my columns in that gridview?
Use the RowDataBound EventHandler:
Count your indexes and make sure you are not trying to access a non-existent column as well.
See link for an example:
http://msdn.microsoft.com/en-us/library/ms178296(v=vs.100).ASPX
grv.RowDataBound += grv_RowDataBound;
private void grv_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.Header)
{
e.Row.Cells[0].Width = new Unit("5%");
e.Row.Cells[1].Width = new Unit("7%");
e.Row.Cells[2].Width = new Unit("12%");
e.Row.Cells[3].Width = new Unit("12%");
e.Row.Cells[4].Width = new Unit("7%");
e.Row.Cells[5].Width = new Unit("7%");
e.Row.Cells[6].Width = new Unit("23%");
e.Row.Cells[7].Width = new Unit("22%");
e.Row.Cells[8].Width = new Unit("5%");
}
}
I created a button that is supposed to view a message in a updatepanel.
I dynamically added through code since the ammount of buttons are relative to how many messages they recieve. I need the button to display a label. Any Ideas?
Here is my code:
I feel like the problem that the scope is limited to the loop. I was going to change the id to increase "lblbody" = 1+=1
$ while (reader.Read())
{
string strrecipient, strsender, strsubject, strbody, strdate, strviewstate;
strdate = "Date Sent: " + reader["date"].ToString();
strsender = "From: " + reader["sender"].ToString();
strsubject = "Subject: " + reader["subject"].ToString();
strbody = reader["body"].ToString();
strrecipient = "To: " + reader["recipient"].ToString();
if (reader["viewstate"].ToString() == "notread")
{
strviewstate = "UnRead";
}
else
{
strviewstate = "read";
}
string strName;
int intName;
intName = 0;
strName = intName.ToString();
Panel pnlNewMess = new Panel();
pnlMess.Controls.Add(pnlNewMess);
pnlNewMess.BorderColor = System.Drawing.Color.LightGray;
pnlNewMess.BorderStyle = BorderStyle.Solid;
pnlNewMess.BorderWidth = 1;
Label lbldate = new Label();
Label lblsender = new Label();
Label lblsubject = new Label();
Label lblbody = new Label();
Label lblrecipient = new Label();
Label lblviewstate = new Label();
Button btnView = new Button();
lbldate.Text = strdate;
lblsender.Text = strsender;
lblsubject.Text = strsubject;
lblbody.Text = strbody;
lblrecipient.Text = strrecipient;
lblviewstate.Text = strviewstate;
btnView.Text = "View Message";
btnView.ID = strsubject;
lblbody.Visible = false;
lblrecipient.Visible = false;
lblviewstate.Visible = false;
//lblbody.ID = "lblBody" + strName;
pnlNewMess.Controls.Add(lblrecipient);
pnlNewMess.Controls.Add(new LiteralControl("<br />"));
if (lblviewstate.Text == "notread")
{
pnlNewMess.Controls.Add(new LiteralControl("<div class='clsmess' style='background-image:url('images/unread.png'); color:white;'>"));
}
else
{
pnlNewMess.Controls.Add(new LiteralControl("<div class='clsmess' style='background-image:url('images/read.png'); color:white;'>"));
}
pnlNewMess.Controls.Add(lbldate);
pnlNewMess.Controls.Add(lblsubject);
pnlNewMess.Controls.Add(lblsender);
pnlNewMess.Controls.Add(btnView);
pnlNewMess.Controls.Add(new LiteralControl("</div>"));
pnlNewMess.Controls.Add(lblviewstate);
pnlNewMess.Controls.Add(new LiteralControl("<br />"));
pnlView.Controls.Add(lblbody);
pnlMess.Controls.Add(pnlNewMess);
}
The only thing I have tried was to set a click event for the button taking the subject lbl.text to a global variabe and then with the click of another button, would compare the subject field with the database and display the lblbody.
btnview.text = lblsubject.text;
SqlCommand CMretMess = new SqlCommand("SELECT body FROM [message] WHERE subject='" + clsGlobals.myGlobals.strSub + "'", connection);
lblBody.Text = CMretMess.ExecuteScalar().ToString();
connection.Close();
Could you do something as simple as this?
btnView.Click += (sender, e) => {
lblbody.Visible = true;
};