Need code for display the text with Image
-
Hi, I'm going to assume that you are passing the text to the age through the page parameter "showtext" (page.aspx?showtext="what to show"). This first example has a button that shows the text:
Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Redirect("ThisPage.aspx?showtext=text")
End SubSub Label1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.PreRender
If Request.QueryString("showtext") <> Nothing Or Request.QueryString("showtext") <> "" Then
Label1.Text = request.QueryString("showtext")
End If
End SubTo show the Image, I assume that you are passing the image location through the parameter "imageloc". It also has the button:
Sub Button1_Click(ByVal sender As Object, byVal e As System.EventArgs) Handles Button1.Click
Response.Redirect("ThisPage.aspx?imageloc=image1.png")
End SubSub PictureBox1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.PreRender
If Request.QueryString("imageloc") <> Nothing Or Request.QueryString("imageloc") Then
PictureBox1.ImageLocation = Request.QueryString("imageloc")
End If
End Sub -
Hi, I'm going to assume that you are passing the text to the age through the page parameter "showtext" (page.aspx?showtext="what to show"). This first example has a button that shows the text:
Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Redirect("ThisPage.aspx?showtext=text")
End SubSub Label1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles Label1.PreRender
If Request.QueryString("showtext") <> Nothing Or Request.QueryString("showtext") <> "" Then
Label1.Text = request.QueryString("showtext")
End If
End SubTo show the Image, I assume that you are passing the image location through the parameter "imageloc". It also has the button:
Sub Button1_Click(ByVal sender As Object, byVal e As System.EventArgs) Handles Button1.Click
Response.Redirect("ThisPage.aspx?imageloc=image1.png")
End SubSub PictureBox1_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles PictureBox1.PreRender
If Request.QueryString("imageloc") <> Nothing Or Request.QueryString("imageloc") Then
PictureBox1.ImageLocation = Request.QueryString("imageloc")
End If
End SubThanks for Your reply but i am using label to display text with Image.i have given the path for the image but i want to display the text on btn click which is retrived frm database.i have givenu small piece of code below protected void btnSubmit_Click(object sender, EventArgs e) { try { if (lblDisplayText.Text = "" && ddlsunsign.Text = "Aries") { return "../../DesignTier/SignImages/ariesstat.jpg"; } . . . . . . } catch (Exception ex) { ex.Message; } } it wuld b very helpful for me if possible give code in C#. Thanks in Advance.
-
Thanks for Your reply but i am using label to display text with Image.i have given the path for the image but i want to display the text on btn click which is retrived frm database.i have givenu small piece of code below protected void btnSubmit_Click(object sender, EventArgs e) { try { if (lblDisplayText.Text = "" && ddlsunsign.Text = "Aries") { return "../../DesignTier/SignImages/ariesstat.jpg"; } . . . . . . } catch (Exception ex) { ex.Message; } } it wuld b very helpful for me if possible give code in C#. Thanks in Advance.
Sorry :-O You could try this:
public string GetImagePath()
{
switch (ddlsunsign.Text) {
case Aries:
return "../../DesignTier/SignImages/ariesstat.jpg";
case Aquarius:
return "../../DesignTier/SignImages/aquariusstat.jpg";
//case Libra, Pisces,...
case default:
return null;
}
}
public string GetStat()
{
switch (ddlsunsign.text) {
case Aries:
return //database code
//etc
case default:
return null;
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
if (GetImagePath()!=null&&GetStat()!=null) {
Response.Redirect("ThisPage.aspx?imageloc=\"" + GetImagePath + "\"&text=\"" + GetStat() + "\"");
}
}
protected void descriptionLabel_PreRender(object sender, EventArgs e)
{
if (Request.QueryString("text")!=null) {
descriptionLabel.Text = Request.QueryString;
}
else {
descriptionLabel.Text = "Error";
}
}
protected void signImage_PreRender(object sender, EventArgs e)
{
if (Request.QueryString("imageloc")!=null) {
signImage.ImageLocation = Request.QueryString("imageloc");
else {
signImage.ImageLocation = //friendly error message;
}
} -
Thanks for Your reply but i am using label to display text with Image.i have given the path for the image but i want to display the text on btn click which is retrived frm database.i have givenu small piece of code below protected void btnSubmit_Click(object sender, EventArgs e) { try { if (lblDisplayText.Text = "" && ddlsunsign.Text = "Aries") { return "../../DesignTier/SignImages/ariesstat.jpg"; } . . . . . . } catch (Exception ex) { ex.Message; } } it wuld b very helpful for me if possible give code in C#. Thanks in Advance.
Here is the old code in C#:
protected void button1_Click(Object sender, EventArgs e) {
Response.Redirect("ThisPage.aspx?showtext=text&imageloc=loc");
}
protected void label1_PreRender(object sender, EventArgs e) {
if (Request.QueryString("showtext")!=null||Request.QueryString("showtext")!="") {
label1.Text = request.QueryString("showtext");
}
}
protected void pictureBox1_PreRender(object sender, EventArgs e) {
if (Request.QueryString("imageloc")!=null||Request.QueryString("showtext")!="") {
pictureBox1.ImageLocation = Request.QueryString("imageloc");
}
}