|
hi iam using asp.net with c#
if (FileUpload1.HasFile)
{
FileInfo branchinfo = new FileInfo(FileUpload1.PostedFile.FileName.Trim());
byte[] branchcontent = new byte[branchinfo.Length];
FileStream branchstream = branchinfo.OpenRead();
branchstream.Read(branchcontent, 0, branchcontent.Length);
branchstream.Close();
cmdsave.Parameters.AddWithValue("@BranchPicture", (branchcontent == null? System.DBNull.Value: branchcontent));
}
else {
cmdsave.Parameters.AddWithValue("@BranchPicture",DBNull.Value);
}
but it is giving error
Type of conditional expression cannot be determined because there is no implicit conversion between 'System.DBNull' and 'byte[]'
can you correct the code where iam going wrong
|
|
|
|
|
You should try...
branchcontent.ToString() == null? null : branchcontent
Hope this will help!
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
hi iam using asp.net with c#
iam using dropdownlist control in update panel control but no selectedindexchange event is firing can you make a change in my code which helps me
<asp:UpdatePanel ID="pannelupdate" runat="server" ><ContentTemplate><asp:DropDownList ID="ddlconnectivity" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlconnectivity_SelectedIndexChanged"><asp:ListItem Value="DSL">DSL</asp:ListItem><asp:ListItem Value="Connect">Connect</asp:ListItem><asp:ListItem Value="Not Available">Not Available</asp:ListItem><asp:ListItem Value="Others">Others</asp:ListItem></asp:DropDownList></ContentTemplate><Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlconnectivity" EventName="SelectedIndexChanged" />
</Triggers></asp:UpdatePanel>
protected void ddlconnectivity_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlconnectivity.SelectedValue == "Dsl" || ddlconnectivity.SelectedValue == "Connect" || ddlconnectivity.SelectedValue == "Others")
{
txtconnectaccount.Visible=true;
}
else {
txtconnectaccount.Visible = false;
}
}
when iam selecting any item it is not performing any action and giving message use EnableEventValidation=true in page directive , i have done like this also but even though it is not performing any action. can you help correct the code which helps me
|
|
|
|
|
|
hi it is giving error when iam selecting items from drop down list no action is performing
error
======
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@ Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
code
====
<asp:UpdatePanel ID="pannelupdate" runat="server" UpdateMode="Conditional" ><ContentTemplate><asp:DropDownList ID="ddlconnectivity" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlconnectivity_SelectedIndexChanged"><asp:ListItem Value="DSL">DSL</asp:ListItem><asp:ListItem Value="Connect">Connect</asp:ListItem><asp:ListItem Value="Not Available">Not Available</asp:ListItem><asp:ListItem Value="Others">Others</asp:ListItem></asp:DropDownList></ContentTemplate><Triggers>
<asp:AsyncPostBackTrigger ControlID="ddlconnectivity" EventName="SelectedIndexChanged" />
</Triggers></asp:UpdatePanel>
protected void ddlconnectivity_SelectedIndexChanged(object sender, EventArgs e)
{
if (ddlconnectivity.SelectedValue == "Dsl" || ddlconnectivity.SelectedValue == "Connect" || ddlconnectivity.SelectedValue == "Others")
{
txtconnectaccount.Visible=true;
}
else {
txtconnectaccount.Visible = false;
}
}
action is not performing can you correct my code where iam going wrong.
|
|
|
|
|
|
try this ....
<asp:AsyncPostBackTrigger ControlID ="YourDropDownName" EventName ="YuorEventName" />
|
|
|
|
|
I have created a web chat application, to get to the webchat user has to login using his username and password. When I was developing my application the redirection sometimes was working, and sometimes not, I didn't really know why, but I wasn't bothered about that then.
Now I wanted to access my webpage by using IIS, I was following this tutorial:
http://www.codeproject.com/KB/aspnet/IIS7ASPNet.aspx
The login page is with this adress: http://localhost/Smiths1/Default.aspx
and it should redirect me to:
http://localhost/Smiths1/SmithChat.aspx?roomID=14
but I don't know why it redirects me to:
http://localhost/Smiths1/Default.aspx?ReturnUrl=%2fSmiths1%2fSmithChat.aspx%3froomID%3d14&roomID=14
and I can't get to the webchat (I still see the login page, but I assume it;s only because the name of it is Default.aspx).
The instruction in login page looks like that:
<code>Response.Redirect("SmithChat.aspx?roomID=14", true);</code>
I don't know what causes whis "error", could someone help me please?
|
|
|
|
|
You problem is not clear. please rephrase your question.
|
|
|
|
|
I think I should start with showing you my code in the login page (I'm using prepared asp login component):
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
SmithChatDataContext data = new SmithChatDataContext();
var user = (from u in data.Users
where u.Username == Login1.UserName
&& u.Password == Login1.Password
select u).SingleOrDefault();
if (user != null)
{
e.Authenticated = true;
Session["ChatUserID"] = user.UserID;
Session["ChatUsername"] = user.Username;
Response.Redirect("SmithChat.aspx?roomID=14", true);
}
else
{
e.Authenticated = false;
}
}
}
and when I run the page from the Visual Studio, it goes to the login page, when I'm trying to login - sometimes it redirects me to the webchat as it should, and sometimes the link after authentication looks like that:
http://localhost:49786/Smiths/Default.aspx?ReturnUrl=%2fSmiths%2fSmithChat.aspx%3froomID%3d14&roomID=14
and I'm still on the login page. I don't know what is wrong.
Anyway, I tried to deploy my application using IIS, so I followed the tutorial which I mentioned about before, and my login page is accessible (http://localhost/Smiths1/Default.aspx) However, after authentication it stays on the login page and the link again looks like that:
http://localhost/Smiths1/Default.aspx?ReturnUrl=%2fSmiths1%2fSmithChat.aspx%3froomID%3d14&roomID=14
|
|
|
|
|
I think it is redirecting to default page because
it is not finding SmithChat.aspx page on it's path.
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
try this
Response.Redirect("SmithChat.aspx?roomID=14", false);
|
|
|
|
|
Thanks, but I've tried that already. It's not redirecting anywhere at all when this boolean is set to false (stays on the default.aspx). I still can't figur out what's wrong
|
|
|
|
|
I have an ordering site with a requirement where I need to allow a user to upload a file and while that file is uploading, allow them to continue on in the page flow. On each page, I wish to be able to check on the status of the file uploading and provide feedback to the user on the status of the upload, such as a progress bar.
I'm looking for ideas on how to begin a file upload and then allow for page navigation without ending the upload. ASP.Net / AJAX are good to use, but not Silverlight
|
|
|
|
|
Interesting problem. The first thing that comes to mind is to use an iframe for the navigation so the file upload is taking place in one page while other pages are displayed in the iframe.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Not a bad idea in general, but unfortunately won't work for my purposes. We cannot place the main page content into an iframe for navigation, it could create a lot of problems for us.
Any other ideas?
|
|
|
|
|
As I'm sure you know the difficulty is keeping the uplaod active while navigating to another page. The thing the pops to mind (pun intended ) is a popup window to handle the upload, however that could be blocked by browser settings, etc.
Although its just a variation on the the same idea you could use ajax calls to refresh the content.
I know the language. I've read a book. - _Madmatt
|
|
|
|
|
|
What if you just open a new pop window and allow the users to upload the files in the popup window
For whowing the progress... There are some solutions for that, just google it
Alexei Rodriguez
|
|
|
|
|
I have an application built using classic asp. I built a page using asp .net (C#) and need to retrieve parameter values passed from the asp page.
Some of them are working - when I use code like MyControl = Request.Form["cmbDepartmentID"];
But for unknown reason - the others are not working.
So, I tried to create a Session object in the asp page, and retrieve it in the asp.net.
In the asp for example - Session("Param") = value
And in the asp.net - MyParam = Session["Param"].ToStrng();
But it doesn't recognize the session object.
What is the way to do it?
The asp page is a huge mumbo-jumbo of vbscript, javascript, html etc. that I don't follow the flow clearly. But I know querystring is not an option here.
Thanks.
|
|
|
|
|
ASP and ASP.Net do not share the same session on the same server by default. Microsoft has a way to implement session sharing[^] but I don't think a lot of people have had good experiences with it.
Have you done any debugging to output all of the Request.Form items to see if they are being posted? I can't remember if Request.Form in ASP.Net is case sensitive or not.
|
|
|
|
|
Hi Gray,
Yes I tried outputting all of them, and some are not being passed to the asp.net. Thats why I can't retrieve them. When I did that - I used the same case wording.
I could try the Session sharing technique you pointed to, but it looks like overkill.
I'll go back and dig further - and let you know.
Thanks.
|
|
|
|
|
|
Hi All,
I've designed a crystal report with a subreport in one of the report footer section. I wanted to print the subreport in new page so I select "New page before" option for that section also to avoid printing a blank subreport I select "Suppress if blank " option also suppressed the blank subreport.
Now section is getting suppressed for blank report but a new page is being added into my report.
Does anybody know how to avoid this situation?
Please help me it's very urgent.
Hope I've cleared my point.
|
|
|
|
|
Put a boundary (with some color and style) to check what's causing the report to extend to new page. It might be because of some extra space (even 1 inch or less) , new page is getting added.
Putting colors/style will help you in finding the reason and resovling it if possible.
|
|
|
|