Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am working on a web development project in asp.net dealing with generating a image based on the user entered length and width.
Mainly we provide them in CSS style
but can we accomplish the same in creating an image with user entered values?
Please Help... any guidance in this regard will be appreciated.
Thanks!!
Posted
Comments
I.explore.code 8-Oct-12 8:46am    
can you not render the image in a default sized div first and then let the user resize the image/div? I suppose that will be easier to achieve and would not really need any server side interactions.
Ash29 8-Oct-12 8:49am    
thanks for that wonderful suggestion,
i hav already placed a image based on the css style with specific height and width.
how can that be changed at runtime?
I.explore.code 8-Oct-12 8:56am    
u can try using jQuery selectors to read height and width from the controls and then use the css function to apply that width and height to the image. See if that works, coz its been a while since i last used something like that so its really just off the top of my head. Give that a go and i will see if i can find something better but don't count on it :)
Ash29 8-Oct-12 8:59am    
Thanks mann.. a sight of relief now :-)
well certainly i wil give a try to the same...
seems like a challenging task though :-\

1 solution

I think I found it:

XML
<script language="javascript" src="Scripts/jquery1.7.js" type="text/javascript"></script>
<script language ="javascript" type="text/javascript">
    $(document).ready(function () {
        $("#btnFU").click(function (e) {
            var w = $("#txtW").val();
            var h = $("#txtH").val();
            $("#actualimg").css("width", w);
            $("#actualimg").css("height", h);
            e.preventDefault();
        });
    });
</script>

<img id="actualimg" src="images/abc.png" alt="some image" style="width:200px" />
<asp:label text="height" id="lblht" runat="server" xmlns:asp="#unknown"></asp:label>
<asp:textbox id="txtH" runat="server" clientidmode="Static" xmlns:asp="#unknown"></asp:textbox>
<asp:label text="width" id="Label1" runat="server" xmlns:asp="#unknown"></asp:label>
<asp:textbox id="txtW" runat="server" clientidmode="Static" xmlns:asp="#unknown"></asp:textbox>
<asp:button id="btnFU" runat="server" text="Resize" clientidmode="Static" xmlns:asp="#unknown" />


The jQuery method css() does the trick when you pass in the values provided by the user. See if this works.
 
Share this answer
 
v2
Comments
Ash29 8-Oct-12 13:07pm    
Thanks alot for that....
infact thanks a million
well i did place the .js file and the image in the necessary location
but on click of the button it is not enlarging or changing.
So, just trying the N probabilities of trial and error :-)
I.explore.code 8-Oct-12 13:20pm    
:) you're welcome! Glad could help! i just noticed code project seems to have added "xmlns:asp:#unknown" to my ASP.NET markup. I hope you haven't copied that too, that just seems to be some gibberish. If indeed you have copied that too, try removing it and see if it works then.
Ash29 8-Oct-12 13:41pm    
Hie,
Its quite relaxing for me as this being my first project since i completed my Masters, was struggling in putting forth the thoughts processed by the peer.
Well with the example provided by you it helped me to atleast assure them that it can be worked out as the way they thought to solve this problem.
And yea i have remove that xmlns
still hard luck :-(
Ash29 8-Oct-12 13:44pm    
Well the main aim behind this exercise is that i need to create a test room for a furniture website.
Sounds interesting isnt it :-)
well on first choosing a room, then appears the number of walls that will actually be present in that room, n finally consider that wall which i am working on, as different people will be having different wall sizes.
So we wanna provide flexibility to the user to choose size as per his desire.
Ash29 8-Oct-12 13:50pm    
well surprising to notice that if i click on resize button without providing any values hen it automatically increases up
but on entering values nothing happens.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900