|
"ctrl.parentElement.parentElement.parentElement"
Code like this is very bad. It assumes that the ctrl has 3 parents and will crash if it does not.
If your problem is in Firefox, you should download Firebug, which will let you debug your javascript inside firefox and see exactly what properties are present and what their values are.
Ridge Howison wrote: so do not have an indepth handle on the workings of .NET or Javascript
Then you're the wrong person for this job, why are you doing it ?
Why did my answer get voted as bad ?
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
1) parentElement should be parentNode [^]
2) IE tends to not insert text nodes for whitespace in the HTML; Firefox does. This doesn't normally make any difference, but your code is making some very specific assumptions as to how many children certain elements will have... this is probably going to trip you up sooner or later. Stop it. Either give the target elements id s and use document.getElementById()[^] to retrieve them, or get a library like jQuery[^] to help you traverse the DOM in a safe, sane manner.
Citizen 20.1.01 'The question is,' said Humpty Dumpty, 'which is to be master - that's all.'
|
|
|
|
|
i have to open an excel reports in my web application
i have created all my reports and when i host my web application and tested my reports in client machine then my excel reports are not opening
i already configured dcom(for excel application launch and access rights) and iis
i am using win 2003 server iis 5.1
win xp client machine
Mohit
|
|
|
|
|
You need to send the excel file with response.binarywrite and hope your user has excel installed.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
Hi All
I am working since 2 days to display images in a datalist and the code used is given below, but its not displaying the images.
I am storing path of the image in database in imagepath coloumn. Kindly help me please.
html code
---------------
<aspataList ID="dlImage" runat="server" RepeatColumns="3" Width="311px" Height="334px">
<ItemTemplate>
<asp:ImageButton ID="imgPhotos" ImageUrl='<%#Eval("imagepath")%>' Height="100%" Width="100%" runat="server" />
</ItemTemplate>
</aspataList>
c# code
----------
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.OleDb;
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
cnOledb = new OleDbConnection("provider=microsoft.jet.oledb.4.0;data source=" + strRootDir + "App_Data\\dbPhotos.mdb");
cnOledb.Open();
string strSelImages = "select imagepath from tblPhotos";
DataSet ds = new DataSet();
OleDbDataAdapter da = new OleDbDataAdapter(strSelImages, cnOledb);
da.Fill(ds);
dlImage.DataSource = ds.Tables[0];
dlImage.DataBind();
cnOledb.Close();
}
}
Thanks
wajid
|
|
|
|
|
Does te HTML look the way you expect it to ? Is the image path you're getting relative to the root of the app, the location of the control/page in question, both, or neither ?
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
I am storing correct paths in database because whenever I am copying nd pasting any of the path in address bar of internet explorer, its showing the image, but when the same coloum of the database is linked to the datalist its not displaying the images.
I am getting some kind of small icons in datalist, but not the one which we generally get when we give wrong path like red x.
Thanks for your reply. Kindly help me with some good answer
|
|
|
|
|
OK - so you marked my answer as bad, and you hope I'll still help you ?
If you're seeing 'some sort of small icon', it's probably the image that's being pointed to. Look at your HTML to try to work out what's going on.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
problem is resolved. Actually I was storing the complete physical of my application in the database like D:\something\myapplicating\images\img.jpg that is why images in the datalist are not displayed. Hope this will help others
|
|
|
|
|
problem is resolved. Actually I was storing the complete physical path of my application in the database like D:\something\myapplicating\images\img.jpg that is why images in datalist are not displayed. I changed the path to images\img.jpg and it worked. Hope this will help others
|
|
|
|
|
Hello everyone,
I've been struggling with this for the last 6 hours, and after a lot of google-ing and research, I thought I'd ask for a little help. See:
a) I have a PDF document exported to a MemoryStream.
b) The control firing the event which leads to the PDF generation and exporting is inside an AJAX UpdatePanel .
So all I want to do is to send the contents of that MemoryStream (containing the PDF) to the browser, so the user sees an "open or download" dialog. As far as I remember, it used to be really easy, at least before AJAX times. Now I've learnt over researching, that the AJAX framework doesn't like Response.Write() at all, but despite my searching, I haven't found a workaround yet.
Here's the way I do it:
Public Sub ExportarPDF(ByVal rpt As CrystalDecisions.CrystalReports.Engine.ReportDocument, ByVal Nombre As String)
Try
Dim ms As IO.MemoryStream = rpt.ExportToStream(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat)
Response.Clear()
Response.Buffer = True
Response.ContentType = "application/pdf"
Response.AddHeader("content-disposition", "attachment; filename=" & Nombre & ".PDF")
Response.BinaryWrite(ms.ToArray())
Response.End()
Catch ex As Exception
Throw ex
End Try
End Sub
And the error it returns (as far as I know, whenever you use Reponse.Write() on an AJAX postback):
Sys.WebForms.PageRequestManagerParserErrorException" The message received from the server could not be parsed. [...] Error parsing near '%PDF-1.2
%????
10'
Where the ? is actually some sort of ? with a question mark inside that I cannot find in the ascii catalog.
Please, if anyone has any ideas of how can I make a browser display the open or download dialog from an AJAX postback, let me know.
Thanks in advance!
Kazz
"Users are there to click on things, not think. Let the archs do the damn thinking."
|
|
|
|
|
You can't send a response like that via AJAX, the browser is simply not expecting it. Nor do you need to, if you have a link and it does a binary write, your page will not refresh, so the end effect is the same as if you used AJAX.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
Code:
using System;
using System.IO;
using System.Configuration;
using System.Data;
using System.Collections;
using System.Text;
partial class Default2 : System.Web.UI.Page
{
private string[] strDictArray;
private bool boolDictionaryLoaded = false;
private int intErrors = 0;
protected void Page_Load(object sender, System.EventArgs e)
{
int iCurrentCount = 0;
string[] arrWords;
string strCompleteOriginal = "";
int iWordCount = 0;
string strAlternative = "";
int i = 0;
if (string.Trim(Request.Querystring["txtContent"]) == "")
{
return; // TODO: might not be correct. Was : Exit Sub
}
else
{
strCompleteOriginal = string.Trim(Request.Querystring("txtContent"));
}
if (!IsPostBack==false)
{
iCurrentCount = 0;
iWordCount = 0;
intErrors = 0;
hfOriginalstring.Value = strCompleteOriginal;
hfCurrentCount.Value = "0";
arrWords = string.Split(strCompleteOriginal, " ");
iWordCount = arrWords.Length;
hfWordCount.Value = iWordCount;
hfErrors.Value = "0";
}
else
{
arrWords = string.Split(hfOriginalstring.Value, " ");
iCurrentCount = hfCurrentCount.Value;
intErrors = int.Parse(hfErrors.Value);
}
txtCurrent.Value = arrWords[iCurrentCount];
if (Request.Form["cmdCancel"] == "Stop")
{
arrWords = string.Split(hfOriginalstring.Value, " ");
iWordCount = hfWordCount.Value;
string strReplace = hfFinal.Value;
int j = 0;
for (j = iCurrentCount; j <= iWordCount - 1; j++)
{
strReplace += arrWords[j] + " ";
}
intErrors -= 1;
stopChecking("frmSpellCheck", "txtContent", strReplace);
return; // TODO: might not be correct. Was : Exit Sub
}
if (Request.Form["cmdNext"] == "Next")
{
arrWords = string.Split(hfOriginalstring.Value, " ");
iWordCount = hfWordCount.Value;
if (txtManual.Value == "")
{
arrWords[iCurrentCount] = lbSuggestions.SelectedValue;
hfFinal.Value += lbSuggestions.SelectedValue + " ";
}
else
{
arrWords[iCurrentCount] = hfFinal.Value;
}
}
}
protected void lbSuggestions_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
Error:
1.System.Web.HttpRequest does not contain a definition for Querystring
2.The best overloaded method match for string.Split(params char[])
3.cannot convert from string to char
4.System.Web.UI.WebControls.TextBox does not contain a definition for value
Please find me a solution
|
|
|
|
|
Well, those errors are all true. Do you know C# at all ? I am assuming you copied some code from the web and have no idea how to understand these error messages. If I were to correct them for you, you'd still be lost. Buy a basic book on C# and read it. Read the error messages, what they say is true.
1 - C# is case sensitive. QueryString
2 - Did you mean to call Split or Replace ? Split expects a char, not a string.
3 - a string is an array of chars
4 - TextBox most certainly does not contain a definition for Value. It DOES have a Text property.
Please try to learn some basics, and perhaps even learn to do some searching, we love to help, but we'd like to assume some basic effort/ability on the part of those asking, too.
Christian Graus
Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.
|
|
|
|
|
Hello,
i have made a very simple file upload app, that i want users to be able to upload images to a folder on my server, well localhost for the time being
here is the simple upload code...
protected void ButtonRegisterDetails_Click(object sender, EventArgs e)
{
String FileName = MyFile.PostedFile.FileName;
String FileContent = MyFile.PostedFile.ContentType;
int FileSize = MyFile.PostedFile.ContentLength;
String justFileName = Path.GetFileName(FileName);
try
{
MyFile.PostedFile.SaveAs(@"C:\Downloads");
ProgressTextBox.Text = "uploaded ok.... i think";
}
catch (Exception ex)
{
ProgressTextBox.Text = ex.Message.ToString();
}
}
The code looks fine but the problem i have is that i keep getting an exception saying that the access to the destination folder is denied.
Access to the path 'C:\Downloads' is denied.
Ive been reading about granting permissions for 2 days now, and although im new to IIS i believe that because i have the NETWORK SERVICE but not ASPNET user available im using IIS 6.
in a disparate attempt to try and solve this i created a new project using the same C# code as above and pointed the images to be saved in a new directory "C:\Downloads". i granted full access permissions to all the users that were listed when i right clicked on the C:\Downloads dir and selected....
Sharing and Security
Security tab
add
Advanced
Find Now
The users that people have said should work "IUSR_mycomputer" and "NETWORK SERVICE" make no difference either, but even by giving all users, well over 60 of them full access permissions it makes no difference.
could it be something to do with the way ASP.NET, or IIS is installed on my machine ??
Im using Windows XP pro 64bit and Visual studio 2008.
basically my question is.... how can i grant write permissions to a folder in my asp.net app as changing permissions in the Sharing and Security properties has done nothing ??
thank you for your time.... please help
Truegilly
|
|
|
|
|
ok ive got it working,
it was my code, i needed to add the file name of the uploaded file
MyFile.PostedFile.SaveAs("C:\\Downloads\\" + justFileName);
also i lost the @ at the beginning
thanks
Truegilly
|
|
|
|
|
Hi,
I am using asp.net 2005.
I have a problem with usercontrol.
I have a usercontrol on my aspx page.
In usercontrol there is a button.
on click event of usercontol button i have to fill gridview which is present on aspx page.
can any one tell me how i will do it.
thanking u.
|
|
|
|
|
well fire the event for filling the gridview on the onclick event of the button
there are plenty of tutorials for binding data to a gridview and its fairly straightforward
We are not a Code Charity
|
|
|
|
|
thanks for replaying me.
but the problem is
my button is in usercontrol and gridview is in aspx page.
how i fire event of usercontrol in aspx page.
please tell me.
|
|
|
|
|
check this out:
http://forums.asp.net/p/1279478/2441374.aspx
and this
http://forums.asp.net/p/1262933/2365263.aspx
We are not a Code Charity
|
|
|
|
|
Hi,
Sorry for the delay...there was a problem in the site..
You need to raise an event to the page. Here is how to do it.
First let’s create delegate and define an event of type of the delegate. And call that event in the button click event.
Add this code your ascx.cs file
public delegate void LoadGridHandler();
public event LoadGridHandler LoadGrid;
protected void Button1_Click(object sender, EventArgs e)
{
this.LoadGrid();
}
Now, in your aspx file, raise that event during the page load of your page.
Take this code..
protected void Page_Load(object sender, EventArgs e)
{
MyControl1.LoadGrid += new Controls_MyControl.LoadGridHandler(MyControl1_LoadGrid);
}
void MyControl1_LoadGrid()
{
//write the method to load you grid
Response.Write("Hi from Gayani");
}
Hope it works
Thx,
Gayani
|
|
|
|
|
thanks a lot.
i fixed my problem.
|
|
|
|
|
Hello!
I've got an aspx-file which I use for AJAX to return different stuff depending on querystring. I one case I return an webusercontrol(.ascx) with a bunch of controls including a couple of validators. When I try to do this:
myWebUserControl.RenderControl(myHtmlTextWriter)
none of the asp:validator-controls gets rendered in html. This includes asp:RequiredFieldValidator and asp:ValidationSummary. What do I have to do in order for those controls to also be rendered?
|
|
|
|
|
In design mode drag the .ascx onto the form. put the control inside a panel
in the page load set panel.style.value = "display:none";
in ajax event when you want to display the ascx set panel.style.value = "";
Did that help?
I didn't get any requirements for the signature
|
|
|
|
|
Hello and thanks for your reply! Actually this did solve part of the problem. Now I do get html for the validators like this:
span id="Login1_validatorReqFieldUserName" style="color: Red; display: none;"
but I don´t seem to get the javascripts that makes the actual validation work.
|
|
|
|