|
i know that is return binary data.
and i know how to convert binary data to image.
but i dont know how to put converted image to page on the fly without saving images in any folder?
We Can Do Anything, If We Want It
|
|
|
|
|
You can use a MemoryStream:
<br />
private static int chunkSize = 10000;<br />
private void writeData(object yourImageBinaryData){<br />
MemoryStream ms = null;<br />
int dataLeft = 0;<br />
<br />
try<br />
{<br />
dataLeft = ((byte[])yourImageBinaryData).Length;<br />
ms = new MemoryStream((byte[])yourImageBinaryData);<br />
<br />
while(dataLeft > 0 && Response.IsClientConnected)<br />
{ <br />
byte[] currentChunk = new byte[chunkSize];<br />
int currentChunkSize = ms.Read(currentChunk, 0, chunkSize);<br />
<br />
Response.BinaryWrite(currentChunk);<br />
<br />
dataLeft -= currentChunkSize;<br />
currentChunk = null;<br />
}<br />
}<br />
catch(Exception e){<br />
throw new Exception("writeData failed. " + e.Message);<br />
}finally{<br />
if (ms != null)ms.Close();<br />
ms = null;<br />
}<br />
}<br />
Hope it helps
Thomas
|
|
|
|
|
thank's for you.
but i want put all image for one user in the page
and Response.BinaryWrite or Response.OutputStream dose not Suport this
We Can Do Anything, If We Want It
|
|
|
|
|
You could putt each image in DataGrid, repeater, listcontrol.
You could also create your own class that contains the image from the database.
Something like this:
First create an empty .aspx page
<%@ Page language="c#" Codebehind="MyImageClass.aspx.cs" AutoEventWireup="false" Inherits="My.Publishing.MyImageClass" %><br />
The code behinde:
using System;<br />
using System.IO;<br />
using System.Drawing.Imaging;<br />
using Millum.Procurement.Imaging;<br />
using System.Runtime.Serialization;<br />
using System.Runtime.Serialization.Formatters.Binary;<br />
using System.Web;<br />
using System.Web.Caching;<br />
using System.Collections;<br />
namespace My.Publishing{<br />
public class MyImageClass : System.Web.UI.Page{<br />
private static int chunkSize = 10000;<br />
override protected void OnInit(EventArgs e){<br />
InitializeComponent();<br />
base.OnInit(e);<br />
}<br />
private void InitializeComponent(){<br />
uploadData();<br />
}<br />
private void uploadData(){<br />
string strID = null;<br />
<br />
strID = (Request.QueryString["attID"] != null)?Request.QueryString["attID"]:(Request.Form["attID"] != null)?Request.Form["attID"]:null;<br />
<br />
byte[] byteImg1 = getImage("select picture from database where id=" + strID );<br />
<br />
writeData(byteImg1);<br />
}<br />
<br />
<br />
private void writeData(byte[] yourImageBinaryData){<br />
MemoryStream ms = null;<br />
int dataLeft = 0;<br />
<br />
try<br />
{<br />
dataLeft = yourImageBinaryData.Length;<br />
ms = new MemoryStream(yourImageBinaryData);<br />
<br />
while(dataLeft > 0 && Response.IsClientConnected)<br />
{ <br />
byte[] currentChunk = new byte[chunkSize];<br />
int currentChunkSize = ms.Read(currentChunk, 0, chunkSize);<br />
<br />
Response.BinaryWrite(currentChunk);<br />
<br />
dataLeft -= currentChunkSize;<br />
currentChunk = null;<br />
}<br />
}<br />
catch(Exception e){<br />
throw new Exception("writeData failed. " + e.Message);<br />
}finally{<br />
if (ms != null)ms.Close();<br />
ms = null;<br />
}<br />
}<br />
<br />
Now the page where the images is viewed, this is an example with
a DataGrid, where the image is displaide in a imagebutton:
<br />
asp:datagrid id="dgImages" runat="server" CssClass="grid" AutoGenerateColumns="False" GridLines="None"<br />
ShowFooter="True"><br />
SelectedItemStyle Font-Bold="True" CssClass="grid_itemSelected"></SelectedItemStyle><br />
EditItemStyle CssClass="grid_itemEdit"></EditItemStyle><br />
AlternatingItemStyle CssClass="grid_itemAlternating"></AlternatingItemStyle><br />
ItemStyle CssClass="grid_item"></ItemStyle><br />
HeaderStyle Font-Bold="True" CssClass="grid_header"></HeaderStyle><br />
FooterStyle CssClass="grid_footer"></FooterStyle><br />
Columns> <br />
asp:TemplateColumn ItemStyle-HorizontalAlign="Center" ItemStyle-VerticalAlign="Top"><br />
ItemTemplate><br />
asp:ImageButton ID="imgFT" runat="server" CommandArgument='<%#DataBinder.Eval(Container.DataItem, "lngImageID").ToString()%>' AlternateText="Show/Download$" CausesValidation="True"><br />
/asp:ImageButton><br />
/ItemTemplate><br />
/asp:TemplateColumn><br />
/Columns><br />
/asp:datagrid><br />
Then you need a ItemCreated method for the datagrid:
<br />
#region Web Form Designer generated code<br />
override protected void OnInit(EventArgs e)<br />
{<br />
InitializeComponent();<br />
base.OnInit(e);<br />
}<br />
<br />
private void InitializeComponent()<br />
{<br />
this.dgImages.ItemCreated += new System.Web.UI.WebControls.DataGridItemEventHandler(this.dgImages_ItemCreated);<br />
this.Load += new System.EventHandler(this.Page_Load);<br />
<br />
}<br />
#endregion<br />
<br />
private void dgImages_ItemCreated(object sender, System.Web.UI.WebControls.DataGridItemEventArgs e)<br />
{ <br />
try <br />
{<br />
if (e.Item.ItemType == ListItemType.Item || e.Item.ItemType == ListItemType.AlternatingItem) <br />
{<br />
DataRowView drv = (DataRowView) e.Item.DataItem; System.Web.UI.WebControls.ImageButton img = new ImageButton();<br />
img = (System.Web.UI.WebControls.ImageButton)e.Item.FindControl("imgFT");<br />
img.Click += new System.Web.UI.ImageClickEventHandler(btnImage_Click); <br />
if(drv != null)<br />
{<br />
int lngImageID = Convert.ToInt32(drv.Row["ID"]);<br />
img.BackColor = Color.Transparent;<br />
img.BorderStyle = BorderStyle.None;<br />
<br />
img.ImageUrl = "../MyImageClass.aspx"?attID=" + lngImageID.ToString();<br />
}<br />
catch (Exception err) <br />
{<br />
}<br />
}<br />
Ofcource you now have to get all the imageIDs from the user:
<br />
DataVies dvAllImageIDs = getAllImageIDsForTheUser();<br />
dgImages.DataSource = dvAllImageIDs;<br />
dgImages.DataBind();<br />
This code is bits and pizes of a hole bigger control, so theres
probably some errors, but you get the point.
Hope it helps
Thomas
-- modified at 4:42 Tuesday 17th April, 2007
|
|
|
|
|
how to create a javascript menubar?
|
|
|
|
|
Hope this Script may help you.
var xcNode = [];<br />
<br />
function xcSet(m, c) {<br />
if (document.getElementById && document.createElement) {<br />
m = document.getElementById(m).getElementsByTagName('ul');<br />
var d, p, x, h, i, j;<br />
for (i = 0; i < m.length; i++) {<br />
if (d = m[i].getAttribute('id')) {<br />
xcCtrl(d, c, 'x', '[+]', 'Show', m[i].getAttribute('title')+' (expand menu)');<br />
x = xcCtrl(d, c, 'c', '[-]', 'Hide', m[i].getAttribute('title')+' (collapse menu)');<br />
<br />
p = m[i].parentNode;<br />
if (h = !p.className) {<br />
j = 2;<br />
while ((h = !(d == arguments[j])) && (j++ < arguments.length));<br />
if (h) {<br />
m[i].style.display = 'none';<br />
x = xcNode[d+'x'];<br />
}<br />
}<br />
<br />
p.className = c;<br />
p.insertBefore(x, p.firstChild);<br />
}<br />
}<br />
}}<br />
<br />
<br />
function xcShow(m) {<br />
xcXC(m, 'block', m+'c', m+'x');<br />
}<br />
<br />
<br />
function xcHide(m) {<br />
xcXC(m, 'none', m+'x', m+'c');<br />
}<br />
<br />
<br />
function xcXC(e, d, s, h) {<br />
e = document.getElementById(e);<br />
e.style.display = d;<br />
e.parentNode.replaceChild(xcNode[s], xcNode[h]);<br />
xcNode[s].firstChild.focus();<br />
}<br />
<br />
<br />
function xcCtrl(m, c, s, v, f, t) {<br />
var a = document.createElement('a');<br />
a.setAttribute('href', 'javascript:xc'+f+'(\''+m+'\');');<br />
a.setAttribute('title', t);<br />
a.appendChild(document.createTextNode(v));<br />
<br />
var d = document.createElement('div');<br />
d.className = c+s;<br />
d.appendChild(a);<br />
<br />
return xcNode[m+s] = d;<br />
}<br />
Regards,
Satips.
|
|
|
|
|
hai
i used this script,then i run this script means showing blank in screen.but no error shown.so plz help.
|
|
|
|
|
http://www.dynamicdrive.com/dynamicindex1/
http://inspire.server101.com/js/mb/
Gautham
|
|
|
|
|
Hi Guys,
I am using the ready made rss code for my site.The problem is that the feeds opens in the same page of my site.I want it to open in a separate page
The rss coding is in the format
If anybody have the coding or suggestions kindly reply.
Thanks
Jith
|
|
|
|
|
Hi all...
How to disable a potion without getting selected in the dropdownlist. See the this http://www.naukri.com/tieups/tieups.php?othersrcp=945 go to Current Location* Dropdownlist, there we can able select the location only not the state names. plz tell me how to do that, its urgent help me.......
Pradeep Reddy
|
|
|
|
|
protected void Page_Load(object sender, EventArgs e)
{
DataTable dt = commonfunctions.fillCategory(1);
}
public static DataTable fillCategory(int catID)
{
DataTable dt = new DataTable();
dt.Columns.Add("CATEGORY_ID", typeof(int));
dt.Columns.Add("CATEGORY_NAME", typeof(string));
dt.Columns.Add("LEVEL", typeof(int));
dt.Columns.Add("PARENT_CATEGORY", typeof(int));
dt = commonfunctions.fillCat(catID, dt, 0);
return dt;
}
public static DataTable fillCat(int catID, DataTable dt, int i)
{
DataTable currdt = new DataTable();
DataTable cdt = new DataTable();
DataTable ccdt = new DataTable();
string query;
query = "SELECT CATEGORY_ID, CATEGORY_NAME, PARENT_CAT_ID FROM CATEGORY_MASTER WHERE CATEGORY_ID = " + catID;
currdt = SqlHelper.ExecuteDatatable(SqlHelper.ConnectionString, CommandType.Text, query);
string name = currdt.Rows[0][1].ToString();
for (int cnt = 0; cnt < i; cnt++)
{
name = "-" + name;
}
dt.Rows.Add(currdt.Rows[0][0], name, i, currdt.Rows[0][2]);
query = "SELECT CATEGORY_ID, CATEGORY_NAME FROM CATEGORY_MASTER WHERE PARENT_CAT_ID = " + catID ;
cdt = SqlHelper.ExecuteDatatable(SqlHelper.ConnectionString, CommandType.Text, query);
foreach (DataRow drc in cdt.Rows)
{
query = "SELECT COUNT(*) FROM CATEGORY_MASTER WHERE PARENT_CAT_ID = " + catID ;
ccdt = SqlHelper.ExecuteDatatable(SqlHelper.ConnectionString, CommandType.Text, query);
if (Convert.ToInt32(ccdt.Rows[0][0].ToString()) > 0)
{
i++;
dt = fillCat(Convert.ToInt32(drc[0].ToString()), dt, i);
i--;
}
else
{
name = drc[1].ToString();
i--;
for (int cnt = 0; cnt < i; cnt++)
{
name = "-" + name;
}
dt.Rows.Add(drc[0], name, i, catID);
}
}
i--;
return dt;
}
---------------------------------------
Here I have just one table.
Category_Master
And Column are :
Category_id
Category_Name
Parent_Category_ID
Join condion is self join.
You can change query and join condtion as per your data.
Regards,
Mayank Parmar
Senior Software Engineer
Amba Tech
Gandhinagar, India
|
|
|
|
|
All the state name values are "select". So the code may be checking if the value is not "select" accept the value. Please try it out with this logic
Regards,
Sylvester G
sylvester_g_m@yahoo.com
|
|
|
|
|
hi guys i am currently using asp.net2 c# to make a website
however i realise i needed some ajax controls so i installed the nessary files
and added the controls( script manager and calender extension)
altohuhg the page run but when the button is click and the date selector is not displayed anyone know y?
|
|
|
|
|
Hi All,
I need to Redirect the page using JavaScript.Is it Possible.If Please Help me.
Thanks and Regards
Narendra
|
|
|
|
|
You can use javascript:window.location.href='testpage.aspx' to redirect through javascript.
Best Regards,
Apurva Kaushal
|
|
|
|
|
|
hi i am trying to use the calendarextension from ajax but
i seem to have a problem it keep saying it need a tag called asp:scriptmanager
however when i try to add it in the page dont regconize it
<asp:ScriptManager runat="Server" EnableScriptGlobalization="true" EnableScriptLocalization="true" / >
|
|
|
|
|
Make sure that the scriptmanager is the first thing (ajax at least) on your page - it must be found before the calandarextension tag...
|
|
|
|
|
yes i done that i seems that the page dosnt regonize asp:scriptmanager do i need to define anything??
|
|
|
|
|
i was testing wit ajax and all i did was create a new c# website fellowed by putting the calender extension control, a textbox and a imagebutton.
setting the calender extension property to link to the textbox and imagebutton
and play.
then it showed an error regarding the script manager
|
|
|
|
|
I created a new ASP.Net website by Visual Studio 2005.
Used language : C#
Database: no use
Then uploaded by menu "Public website" is get error:
Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.
Source Error:
Line 24: ASP.NET to identify an incoming user.
Line 25: -->
Line 26: <authentication mode="None">
Line 27:
Line 28:
|
|
|
|
|
Problem in assigning values to ItemArray...
I am assigning a new value (100) to the existing cell...
But the original value remains unaltered...
Here is the code:
ds.Tables[0].Rows[0].BeginEdit();
ds.Tables[0].Rows[0].ItemArray[0] = 100; ds.Tables[0].Rows[0].EndEdit();
Please help me.
Thank You.
Arun Kumar.A
|
|
|
|
|
Hi,
Try this.
ds.Tables[0].Rows[0].BeginEdit();
ds.Tables[0].Rows[0][0] = 100;
ds.Tables[0].Rows[0].EndEdit();
I hope this will help you.
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
Hi,
Thank U for Ur reply.
I will try this out.
Regards,
Arun Kumar.A
|
|
|
|
|
Some people don't know how to encrypt and later decrypt connectionStrings section of your web.config file. I've included a batch file that I use for this all the time. Hope this helps.
-START CRYPT.CMD-
@ECHO OFF
REM NOTE: THIS ASSUMES YOU HAVE INSTALLED VISUAL STUDIO 2005
REM IN THE DEFAULT LOCATION. CHANGE THE TOOL= TO REFLECT
REM YOUR LOCATION IF THIS DOES NOT WORK
set TOOL=C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\
IF "%1"=="" GOTO SYNTAX
IF "%1"=="/e" GOTO ENCRYPT
IF "%1"=="/E" GOTO ENCRYPT
IF "%1"=="/d" GOTO DECRYPT
IF "%1"=="/D" GOTO DECRYPT
GOTO SYNTAX
:ENCRYPT
ECHO Encrypting Connection Strings in %2
"%TOOL%aspnet_regiis.exe" -pe "connectionStrings" -app "%2" >NUL
GOTO END
:DECRYPT
ECHO Decrypting Connection Strings in %2
"%TOOL%aspnet_regiis.exe" -pd "connectionStrings" -app "%2" >NUL
GOTO END
:SYNTAX
ECHO INVALID SYNTAX
ECHO CRYPT.CMD
ECHO -------------------------------------------------
ECHO PURPOSE: ENCRYPTS/DECRYPTS the connectionStrings
ECHO section of the Web.Config File for the supplied
ECHO website.
ECHO -------------------------------------------------
ECHO Usage:
ECHO.
ECHO ENCRYPTING THE CONNECTION STRING
ECHO CRYPT /e /WebsiteName
ECHO.
ECHO DECRYPTING THE CONNECTION STRING
ECHO CRYPT /d /WebSiteName
GOTO ENDCLEAN
:END
ECHO Completed..
GOTO ENDCLEAN
:ENDCLEAN
SET TOOL=
-END CRYPT.CMD-
~ CodeDoctor ~
|
|
|
|
|