Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Need code for display the text with Image

Need code for display the text with Image

Scheduled Pinned Locked Moved ASP.NET
csharpasp-net
5 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sridevi14
    wrote on last edited by
    #1

    I want to display the text in the same form when submit btn is clicked.i need to display the image along with the text.i have 2 dropdown boxes n a text field.as i am new to ASp.net Programming thanks in advance

    L 1 Reply Last reply
    0
    • S sridevi14

      I want to display the text in the same form when submit btn is clicked.i need to display the image along with the text.i have 2 dropdown boxes n a text field.as i am new to ASp.net Programming thanks in advance

      L Offline
      L Offline
      lucjon
      wrote on last edited by
      #2

      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 Sub

      Sub 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 Sub

      To 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 Sub

      Sub 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

      S 1 Reply Last reply
      0
      • L lucjon

        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 Sub

        Sub 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 Sub

        To 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 Sub

        Sub 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

        S Offline
        S Offline
        sridevi14
        wrote on last edited by
        #3

        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.

        L 2 Replies Last reply
        0
        • S sridevi14

          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.

          L Offline
          L Offline
          lucjon
          wrote on last edited by
          #4

          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;
          }
          }

          1 Reply Last reply
          0
          • S sridevi14

            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.

            L Offline
            L Offline
            lucjon
            wrote on last edited by
            #5

            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");
            }
            }

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups