Question

was trying to switch from button to hyperlink(previous post) but couldnt get it working so have decided to use the link button instead.

in my aspx page I am using

<script type ="text/javascript">
      function showImg(url) 
      {
                  $("#imagePreview").attr("src", url);

       }
</script>

        <div style="height:50px; margin-top:25px; margin-bottom:25px;">
            <img id="imagePreview" alt="" width="30" height ="30"></img>
        </div>

then in my ascx page I am using

<input type="button" onclick='javascript:showImg("<%# FieldValueString %>")' />

this works fine, when the button is clicked the pic is displayed below however I want a link button instead.

Ive tried the examples on http://www.devmanuals.com/tutorials/ms/aspdotnet/linkbutton.html but no joy,

iv tried

<asp:LinkButton
        ID="LinkButton1"
        runat="server"
        Text="Preview" 
        Font-Bold="True"
        ForeColor="Maroon"

        PostBackUrl='javascript:showImg("<%# FieldValueString %>")' />

but nothing happens when I click the button do I have to add anycode to the .cs file?

Please help

thaks

Was it helpful?

Solution

You are using the incorrect property. Try this:

<asp:LinkButton
        ID="LinkButton1"
        runat="server"
        Text="Preview" 
        Font-Bold="True"
        ForeColor="Maroon"
        OnClientClick='javascript:showImg("<%# FieldValueString %>"); return false;' />
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top