TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Abraham Olatubosun
NA
471
114.7k
Image Not show on Cloud Page But shows on my Machine
May 10 2017 1:41 AM
Dear Code Masters,
Good day to you all, I have a web page that have a textbox and a button for searching student record.
if the student id is entered in the textbox and the button is clicked the c# code behind search and displayed the record if found. The database structure is shown below :
once we search the record "cis/001" i expect the name, RegNo and the image to displayed on my development machine it worked fine, but after deploying both the database and the files to the cloud it is not working.
i have tried using this code:
Image1.ImageUrl =
"ImageHandler.ashx?id="
+ "CIS/001"
DT = ConnectAll.GetTableID(id);
foreach
(DataRow r
in
DT.Rows)
{
Byte[] bytes = (Byte[])r[
"picture"
];
string
Base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
Image1.ImageUrl =
"data:image/png;base64,"
+ Base64String;
}
;
the imageHandler page is a GenericHandler which have the following code:
public
void
ProcessRequest (HttpContext context) {
//context.Response.ContentType = "text/plain";
//context.Response.Write("Hello World");
try
{
string
id = context.Request.QueryString[
"id"
].ToString();
using
(SqlConnection cn =
new
SqlConnection(ConnectAll.ConnectMe()))
{
cn.Open();
string
SQL =
"Select * from tbl_studReg where id ="
+id;
SqlCommand cmd =
new
SqlCommand(SQL, cn);
//cmd.CommandType = CommandType.Text;
//cmd.Parameters.AddWithValue("@id", id.ToString());
SqlDataReader r = cmd.ExecuteReader();
while
(r.Read())
{
context.Response.BinaryWrite((
byte
[])r[
"picture"
]);
}
}
}
catch
(Exception ex)
{
}
}
these didn't work, i also tried the following code too
DT = ConnectAll.GetTableID(id);
foreach
(DataRow r
in
DT.Rows)
{
Byte[] bytes = (Byte[])r[
"picture"
];
string
Base64String = Convert.ToBase64String(bytes, 0, bytes.Length);
Image1.ImageUrl =
"data:image/png;base64,"
+ Base64String;
}
above i have a class that return a datatable (DT)
all these did wor either but on my machine both method work fine displaying the image and the other records. Please can anyone help me?
thank you all
Reply
Answers (
4
)
return value to the main fuction
show text inside datagridwiev cell