Can you dynamically set the image url in a mobile form mobile image ?

I am testing mobile forms, I have created a mobile form with a mobile image.

 <mobile:Image ID="Image6" Runat="server"   ImageUrl="<%#Prodphoto%>" >

 

I would like to set the image based on the selected value as follows

 private string _prodphoto;
    public string Prodphoto
    {
        get
        {
            return _prodphoto;
        }
        set
        {
            _prodphoto = value;
        }
    }

 

 This is where i set the value

    _prodphoto = "~/Images/" + prod.thumbnail;

 

This does not seem to work , has anyone any ideas ?

 

Thanks
 

0
Bubbles2
1/11/2008 10:43:09 AM
asp.net.mobile_devices 3052 articles. 0 followers. Follow

5 Replies
734 Views

Similar Articles

[PageSpeed] 17

Hi Bubbles2,

You should add the following code to Page_Load event:

this.DataBind();

It will work.

Best regards,
Guang-Ming Bian - MSFT


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Guang
1/15/2008 7:52:20 AM

 Hi

 

thanks for your reply but it does not work , the main code is below if you have any other idea please

the section concered is in bold

or if you have an example of working code 

 

Thanks 

 ======  Code =======

public partial class _Default : System.Web.UI.MobileControls.MobilePage
{
    private System.Collections.Generic.List<CartItem> items;
  
    static ShoppingCart  cart;
    private Order order;
    private Customer cust;
    private string _prodphoto;
    public string Prodphoto
    {
        get
        {
            return _prodphoto;
        }
        set
        {
            _prodphoto = value;
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        this.DataBind();
    }

 protected void ProductList_ItemCommand(object sender, ListCommandEventArgs e)
    {
        //
        // Called when we select product from list
        //

        if (cart == null)
        {
            cart = new ShoppingCart();
        }
       
        ProductsTableAdapter prodadapt = new ProductsTableAdapter();
        MatrixDB.ProductsDataTable prods = prodadapt.GetByProd(e.ListItem.Value);
        foreach (MatrixDB.ProductsRow prod in prods)
        {
            String pid = prod.productid;
            lblprodid.Text = pid;
            String nam = prod.longtext.Replace(System.Environment.NewLine, " ");
            lblname.Text = nam;
            Decimal pric = prod.price;
            lblprice.Text = pric.ToString();
            String cat = prod.catid;
            txtQty.Text = "1";
            _prodphoto = "~/Images/" + prod.thumbnail;

        }

 ========= ASPX =======

 <mobile:Form id="ProductDetail" runat="server"   >
    <mobile:Image ID="Image3" Runat="server" Font-Size="Small" ImageUrl="~/Images/Matrix.gif">
    </mobile:Image>
      <mobile:Label ID="lblprodid" Runat="server" Visible="False">Label</mobile:Label>
      <br />
      <mobile:Label ID="lblname" Runat="server" Wrapping="Wrap">
      </mobile:Label>
      <br />
                <mobile:Label ID="lblprice" Runat="server">Price</mobile:Label>
      <br />
      <mobile:TextBox ID="txtQty" Runat="server">
      </mobile:TextBox>
      <br />
      <mobile:Image ID="Image6" Runat="server"   ImageUrl="<%#Prodphoto%>" >
      </mobile:Image>
      <br />
 
    
    <mobile:Command ID="Command3" Runat="server" Text= "<%$ Resources:Resource,mfcont%>" OnClick="Command3_Click" ></mobile:Command>
   
      <mobile:Command ID="Command4" Runat="server"
      Text= "<%$ Resources:Resource,mfretcat%>" OnClick="Command4_Click"></mobile:Command>
     
        <mobile:Command ID="Command5" Runat="server"
      Text= "<%$ Resources:Resource,mfquit%>" OnClick="Command5_Click"></mobile:Command>
      
      </mobile:Form>

 

0
Bubbles2
1/15/2008 11:50:34 AM

Hi Bubbles2 ,

Please  keep in mind, you should set  Prodphoto property before invoking this.databind() in page_load, you set the value in ProductList_ItemCommand event, I don't know when does the event fire. You can set a breakpoint at this.databind() line code, where watch Prodphoto property value, you will know the reason.

Below is a sample , it works fine in my local:

protected void Page_Load(object sender, EventArgs e)

{

this.DataBind();

}

private string m_Prodphoto = "~/Image/Image001.jpg";
public string Prodphoto
{

get { return m_Prodphoto; }

set { m_Prodphoto = value; }

}

Best regards,
Guang-Ming Bian - MSFT


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Guang
1/16/2008 9:19:19 AM

 Hi Thanks a lot

I put the Data bind before I set the active form and it works great thanks again.

   this.DataBind();
        ActiveForm = ProductDetail; 

 

Can you suggest a doucuments which describes the sequence in which events are fired ? 

Big Smile 

0
Bubbles2
1/16/2008 6:17:44 PM

Hi Bubbles2,

See following document:
http://msdn2.microsoft.com/en-us/library/aa719775(vs.71).aspx

 

Best regards,
Guang-Ming Bian - MSFT


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Guang
1/17/2008 8:24:33 AM
Reply:

Similar Artilces:

How can set an image from SystemDrawing.Image into WebControls.Image?
I want directly to set an image from SqlServer to the webform. Do you know how to do it ? please tell me. In the window form I saw a method to set an image from SqlServer: byte[] imgData=(byte[])dr["PictureFile"] // dr is SqlDataReader when call data from SqlServer MemoryStream ms = new MemoryStream(imgData); PictureBox1.Image = System.Drawing.Image.FromStream(ms); ms.Close(); but I have not yet seen any method set an image from SqlServer to WebForm. Have you seen it please tell me, thanks. ...

Set Image URL of image in GridView template field dynamically
Hi, I have a gridview, gvSearchResults, and within the gridview I have a number of columns. 2 of the columns are template fields. One template field contains a Label lblPicURL, which is bound to a sql DB field. The other template field contains an image, imgThumb. In my page_load I have the following...  foreach (GridViewRow rowItem in gvSearchResults.Rows) {Label lblPicURL = rowItem.FindControl("lblPicURL") as Label; Image imgThumb = rowItem.FindControl("imgThumb") as Image;imgThumb.ImageUrl = ConfigurationManager.AppSettings.Get("ImageURL")...

Backcolor to mobile:link in mobile web form in mobile .net site
Hello every one  How to set back ground color to mobile: link in mobile web formI used backcolor property but doesn't work. Help me.Thank you.. ...

ADO.net problem: i can not view image data for the rest of my table rows except the image for the first row but i can read all the other non image fields for all rows.
Hi i have a table with the following fields imgid............int imgdata........image imgtitle.........varchar(max) imgType........varchar(max) imgLength.....bigint incident_id.....int i have no problem with uploading the image but viewing the uploaded image(s) in a gridview has caused me great pain. The probelm is i have two pages. page1 grabs the image to display and page2 has a gridview that displays the grabed image. I wanted to have an sql statement like SELECT * FROM mytable WHERE incident_id=someValue. IF i have 5 records in this table and i view page2 ...

!!!!! Image on master page wont show when image url is set to a image from content page !!!!!!
 Hi guys, I have this problem which i cannot seem to understand... here goes... i have a master page and an image control on it....it is a social networking website and then i have a content page..there is a link button on the master page when when clicked shows a modal popup which has a fileupload control and a user can submit an image file...when he does so the image get saved in a directory and also its complete address is saved in the database...now 2 problems... after committing these actions (on the master page code file ) i set the image url to the saved path ...

How to Insert Image Url and Display the Image of that Image Url in the Grid View?
Any one can help me out about this- How to Insert Image Url and Display the Image of that Image Url in the Grid View Hi You can add HyperLink control to Gridview by setting its ImageUrl and NavigationUrl property Please refer example. <asp:HyperLink ID="HyperLink1" ImageUrl="images/image.gif" NavigateUrl="PageUrl.aspx" runat="server">HyperLink</asp:HyperLink>Please mark the post as answered if it helped you. Hi sandynaidu, This is easy to solve. Assuming that your GridView's ID is gv, that you want to have the image in your firs...

How to use an alternate image url if first image url can't be found
 Hello,I have a product detail page that pulls in a picture and some product details for a product when a user clicks a link in a gridview on another page.  The image files have names like: 1000k.jpg, but for some products the img file names are like: 1000w.jpg.  I want to be able to look for the "w" version if the "k" version can't be found.  I was able to solve a similar problem with product detail text files by using "error catching", but since the inability to find an image url doesn't raise an error, I'm at a loss as to how I...

Setting image URL for image component in Javascript
I have a javascript that show a layer with an image in it. The image is the image component from the toolbox (in VS2005).Now i would like to change the path of the image in the javascript, but nothing happens. This is the code i have tried:       document.getElementById('imagepop').src = "C:\Fish.jpg";and        document.getElementById('imagepop').ImageUrl = "C:\Fish.jpg";But this doesnt work,and it dont give and error or anything. The 'imagepop' is the image control  Try this:...

set image url programmatically for image control
I have a print page that uses an image control to display an image that is saved in a directory that is dynamically created upon a session start. I have the path readily available for the image control....but I am failing to get the image to display in the image control.... what is the syntax to properly set the url for an image control programmatically in the code behind?   the control is named printImage   thanks in advance   Eric printImage.src= printImage.ImageUrl = "your URL";simple as that. ]|[ I am not getting the .src in intellisense for the...

Uploading image in Mobile Form
Hi, im new to mobile forms and want to ask if it is possible to upload image or a text file via mobile form. AFAIK uploading file won't work with mobile devices because those don't offer such capabilities. ASP.NET Whidbey itself does not have a mobile form. The Mobile form is part of the v1.x support for Mobile Controls. There is no 'file upload' control in the mobile controls. In Whidbey controls, we do have a file upload control <asp:fileupload which provides some mobile support. This is acheived using adapters and also a capability on the browsercapabilities called supportsFileU...

Can't set image on image control
I'm trying to load an image but it doesn't show, the code is this:  this.Image1.ImageUrl = @"C:\image1.jpg"; i can only see the images i set in the control in design mode (setting the imageurl property..and only show  the images in the Resources folder) what can i do??VBA Well you can't set it as path on your drive, you need to give it a URL.  When you page is served up, the person viewing the page has no access your harddrive directly so you need to put the image in a directory that is available to the web. Put the image in your application di...

Can I display an image without getting the image from a URL?
From what I've read, it appears you can take an image and create a thumbnail of it with the result being a type 'image'. However, a search of dozens of sites suggests (hopefully this isn't true) that one always uses the URL of an image file to get the image to a control--meaning I can't just use the image created from the workup of an original image. I'm posting the demo code I'm trying, hoping that maybe I'm missing one or two easy steps.    Dim FullImage As Image = Image.FromFile("C:\temp\Picture1.jpg") ...

set image controls url dynamically
i have a datagrid and an image control in test.aspxi want set the url of image control according to what is shown in datagrid.for example, if datagrid shows "Apple" then load Apple.gif to image control.can anyone help me with thisthanks <asp:Image NavigateUrl ='<%#Container.DataItem("Type") & ".gif"%>' ........Bug [MCSD]...

Imaging, but not imaging
We multicasted to 43 machines. Updated the image on the master. Multicasted the updated image to 36 machines. (the other 7 wouldn't join the session for some unknown reason). I visually verified that all 36 were imaging. One of the 8 which didn't rename appears to not even have been imaged. The problems with the previous image were still there. It's as though the machine didn't image even though I saw it take part in the session and the temp bar going across the screen. What the heck's going on here? AlaN As a try, what happens if you boot either to PXE ...

Web resources about - Can you dynamically set the image url in a mobile form mobile image ? - asp.net.mobile_devices

Placebase team at Apple file “Schematic Maps” patent dynamically detailing important data
In a report from Computerworld way back in 2009, we learned that Apple had quietly acquired Maps API company Placebase. Then, founder of Placebase ...

Apple's Lightning port dynamically assigns pins to allow for reversible use
... a closer look at how Apple's new Lightning connector works, and has come to the conclusion that the 8 pins on each side of the plug are dynamically ...

In a dynamically typed language, is it a bad idea to return different data types?
In some cases, returning different types from a single function works.

Urlbox Launches Screenshots-as-a-Service Platform to Dynamically Update Galleries
... changes. Launched yesterday, Urlbox allows anyone with a gallery displaying website screenshots to automate the process and keep them dynamically ...

Everything.me launcher dynamically adapts to what you’re doing right now
... phone according to what you’re doing. Perform a search for ‘football’ and your background will change to the NFL logo. A launcher that dynamically ...


A YouTube Experiment Resizes the Player Dynamically
There's a new YouTube experiment that changes the video player's size, depending on the browser window's size. When resizing Chrome's window, ...

Apple Granted “Dynamically Changing Cursor for User Interface” Patent, Originally Filed in 2003
... a utility patent that covers the use of the mouse cursor that changes according to the context of the task it is engaged in. Called a “Dynamically ...

Atmel's FPSLIC II Dynamically Reconfigurable SoC Supports "Silicon-Sharing" For Peripherals & Interfaces ...
Silicon-Sharing Fits 200K Gate Design into 40K Gate FPSLIC II's, Cuts Power Drain by 97%

Everything.me Launcher Wants to Dynamically Change Phones Based on Location, Interests, and Mental State ...
What if your phone’s launcher dynamically changed based upon interests, your location, or topics you had in mind at a specific moment? A new ...

Resources last updated: 12/1/2015 8:08:56 AM