|
The Server.MapPath() actually returns the physical location of a file based upon a relative path provided to it. So, while saving the image, use of Server.MapPath() is the correct way to obtain the physical path for saving the file.
But, while you have to display the file in the <asp:image> server control, you should assign a relative URL of the image to the Image1.ImageUrl property. Assuming that, you are storing the image under the "/hint" folder (Inside your web application root folder), you should write the following code for displaying the image:
Image1.ImageUrl = "~/hint/" + fileName
|
|
|
|
|
thanks a lot. Its working perfect.i did
Image1.ImageUrl = "~//hint//" + fileName
suchita
|
|
|
|
|
I have a ListView which is filled by generic list of type MyClass. I can easily bind data from this list into ListView. But I have problems with reading data in opposite direction. This is my class:
public class MyClass
{
public int id { get; set; }
public string name { get; set; }
}
I have also generic list of type MyClass:
List<MyTest> list = new List<MyTest>();
Finally I bind data to ListView this way:
ListView1.DataSource = list;
ListView1.DataBind();
My ListView template:
<asp:ListView runat="server" ID="ListView1">
<LayoutTemplate>
<table runat="server" id="table1" >
<tr runat="server" id="itemPlaceholder" ></tr>
</table>
</LayoutTemplate>
<ItemTemplate>
<tr id="tr" runat="server">
<td id="td1" runat="server">
<asp:TextBox ID="tb1" runat="server" Text='<%#Eval("id") %>' />
</td>
<td id="td2" runat="server">
<asp:TextBox ID="tb2" runat="server" Text='<%#Eval("name") %>' />
</td>
</tr>
</ItemTemplate>
</asp:ListView>
How can I read data from ListView into my List list?
The operation of reading ListView data into List generic list should begin after clicking the button "GetData".
I saw the following advice:
List<MyClass> list = ListView1.Items
.Select(lvi=>lvi.DataItem as MyClass)
.ToList();
but it does not work - the DataItem property of each Item of ListView has null value.
The point is that I have generic list with data. I am binding this data into ListView which can be edited by user. After that after click Save or GetData data from ListView is read into generic list of MyClass type.
|
|
|
|
|
hi,
i have got 3 text boxes in my content page. on the press of enter key in textBox1 focus should be on textBox2 and there on press of enter key focus should be on textBox3. after pressing enter key there, button click event should be called.
please help me with some code
thanks in advance
regards,
dittu
|
|
|
|
|
Use javascript, here [^]is a good google search result for using KeyEvents with javascript.
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
Hi,
When designing class how should understand, it implement as Static or public?
|
|
|
|
|
Hi,
You can confirm it from the class access modifier at class declaration part which displays under namespace node.
Rajendra Prasad Panchati
.Net/Sharepoint Software Enginner
Hyderabad.
|
|
|
|
|
This helps to explain it: Static Classes[^].
"If you think it's expensive to hire a professional to do the job, wait until you hire an amateur." Red Adair.
nils illegitimus carborundum
me, me, me
|
|
|
|
|
If you understand Static class concept properly, then you will automatically come to know which method best suits your requirement. If the class is not specific to a particular instance or otherwise if you want some logic shared among all the users then you can go for static classes.
MSDN - Static Classes and Static Class Members[^]
|
|
|
|
|
Hi
Does anyone know where I can find examples and/or explanations on how to implement Structure Maps/Dependency Injection in C#? I have tried finding examples on the Internet, but what I found was not very good.
|
|
|
|
|
|
Yes, I already found that one too, but it doesn't go into the level of detail I want. I am looking for a worked example with explanation that I can use.
|
|
|
|
|
hi,
i tried to use check box in asp.net. well when i run the program, i checked the checkbox but when it process, it is taking checkbox as unchecked. Why this happens ? How to avoid this ?
suchita
|
|
|
|
|
You are surely doing something wrong.
Have a look here with lots of sample examples: CheckBox Class[^]
|
|
|
|
|
SayamiSuchi wrote: well when i run the program, i checked the checkbox but when it process, it is taking checkbox as unchecked.
I can't understand what you post. Explain little more clearly.
|
|
|
|
|
Are you assigning the value of the checkbox outside of an if(!IsPostBack) statement? If so your view state value is being wiped. If you are using DataBinding, make sure your DataBind call is wrapped inside of an if(!IsPostBack) as well.
|
|
|
|
|
i am using that in the button click event.. will if(!IsPostback) be used in that event ?
suchita
|
|
|
|
|
is the checkbox's enableViewState false?
|
|
|
|
|
Hi Suchita,
Please ensure that to put IsPostback condition in page load event.when u call button click event, it'll be postback to the same page and page load then button click events fires. so check it and keep the condition.
Rajendra Prasad Panchati
.Net/Sharepoint Software Engineer.
Hyderabad.
|
|
|
|
|
thanks all so much..it worked now..
suchita
|
|
|
|
|
Hi All,
In my website there is facility that user can send mail using it own email SMTP setting. some user is sending mail success fully but some facing problem for this there is option in config page in which user have to enter his SMTP setting. And also there is test button when users press a test button and if any wrong entry (username, password, smtpServer) then I want to show pop message accordingly.
Is any way in which we can identified that what is wrong entry (username, password or mail server) because I want to give message like "wrong username or wrong SMTP server?
Thanks
|
|
|
|
|
There isn't really anyway to check. For instance, in a hosting environment two SMTP servers could be 10.54.16.10 and 10.54.16.20. If they enter the former when they should using the latter, how can tell the difference? It is a valid address, just the not the correct one for them.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Send a test message and catch SmtpException and check the SmtpStatusCode.
|
|
|
|
|
Hi Samarjeet,
If you give wrong server entry, however It'll give an error like "Relay access denied on 5.7.xx" like that and if u give a wrong credentials it'll throw an error like "Could not connect to the host...". From these errors you can show your custom message to the user. I hope u understand it .
Rajendra Prasad Panchati
.Net/Sharepoint Software Enginner,
Hyderabad.
|
|
|
|
|
Hi,
firstly, sorry if I post it for 2nd times. because its a week I stuck in this problem
I am trying to build up my knowledge regarding ASP.Net and new things which I read from books. Frankly, its few days I got this error. after running my code I see this error
<br />
No matching bindings are available, and the type is not self-bindable. Activation path: 2) Injection of dependency CommunityUserRepository into parameter _rep of constructor of type AccountController 1) Request for AccountController <br />
it is the source code
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Ninject.Core;
using SportsStore;
using SportsStore.WebUI.Controllers;
using System.Web.Routing;
using Ninject.Modules;
using Ninject.Core.Modules;
using SportsStore.Domain.Abstract;
using System.Configuration;
using SportsStore.Domain.Concrete;
namespace SportsStore.WebUI.Infrastructure
{
public class NinjectControllerFactory : DefaultControllerFactory
{
private IKernel Kernel = new StandardKernel(new SportsStoreServices());
protected override IController GetControllerInstance(RequestContext context,Type controllerType)
{
return controllerType == null ? null
: (IController)Kernel.Get(controllerType);
}
private class SportsStoreServices : StandardModule
{
public override void Load()
{
Bind<IProductRepository>().To<SqlProductRepository>().WithConstructorArgument
("connectionString", ConfigurationManager.ConnectionStrings["AppDb"].ConnectionString);
}
}
}
}
error occure in this line
<br />
protected override IController GetControllerInstance(RequestContext context,Type controllerType)<br />
{<br />
return controllerType == null ? null<br />
: (IController)Kernel.Get(controllerType); <br />
<br />
Could you please help me?
|
|
|
|