I have below code which convert text to imag on page load
I want this to happen before any other javascript function..I have a javascript function function init()(in aspx page)..I want the below code to happen before function init() how do i do that?
<asp:Label ID="Label1" runat="server" Text="1234" /> Dim text As String = Label1.Text.Trim()
Dim bitmap As New Bitmap(1, 1)
Dim font As New Font("Arial", 25, FontStyle.Regular, GraphicsUnit.Pixel)
Dim graphics As Graphics = Graphics.FromImage(bitmap)
Dim width As Integer = CInt(graphics.MeasureString(text, font).Width)
Dim height As Integer = CInt(graphics.MeasureString(text, font).Height)
bitmap = New Bitmap(bitmap, New Size(width, height))
graphics = Graphics.FromImage(bitmap)
graphics.Clear(Color.White)
graphics.SmoothingMode = SmoothingMode.AntiAlias
graphics.TextRenderingHint = TextRenderingHint.AntiAlias
graphics.DrawString(text, font, New SolidBrush(Color.FromArgb(255, 0, 0)), 0, 0)
graphics.Flush()
graphics.Dispose()
Dim fileName As String = Path.GetFileNameWithoutExtension(Path.GetRandomFileName()) & ".jpg"
bitmap.Save(Server.MapPath("/imgs/12.jpg") & fileName, ImageFormat.Jpeg)
According to your description, as far as I know, execute JS function is after page_load event finish. For more details, you can refer to
ASP.NET Page Life Cycle Overview, this article will introduce the order of event executed. For explain this, I make a sample show how to run JS and page_load!
This result is show that after dynamically create a label control, then add style. If page execute JS before page load, JS will can not find the element! I hope you can understand my meaning, if this reply can not solve your problem, please let me know!
Best Regards,
Eric Du
MSDN Community Support
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.
Member
200 Points
691 Posts
saving image with specific name before javascript function
Nov 23, 2016 12:01 PM|Lexi85|LINK
hello
I have below code which convert text to imag on page load
I want this to happen before any other javascript function..I have a javascript function function init()(in aspx page)..I want the below code to happen before function init() how do i do that?
Contributor
6730 Points
2715 Posts
Re: saving image with specific name before javascript function
Nov 24, 2016 06:40 AM|Eric Du|LINK
Hi Lexi85,
According to your description, as far as I know, execute JS function is after page_load event finish. For more details, you can refer to ASP.NET Page Life Cycle Overview, this article will introduce the order of event executed. For explain this, I make a sample show how to run JS and page_load!
Here is the sample code:
Result:
This result is show that after dynamically create a label control, then add style. If page execute JS before page load, JS will can not find the element! I hope you can understand my meaning, if this reply can not solve your problem, please let me know!
Best Regards,
Eric Du
Please remember to click "Mark as Answer" the responses that resolved your issue.
If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.