|
Do not cross post. Stick to appropriate forum and be patient for replies.
|
|
|
|
|
choose a single forum to ask your question, and stick to it.
|
|
|
|
|
Hello All,
I need to loop inside asp.net page and get all the controls IDs inside array list but it always count the controls as 5 and never get any controls i will appriciate it if any one can help me
thanks in advanec
eslam soliman adam
public partial class Test2 : System.Web.UI.Page
{
ArrayList numbers;
protected void Page_Load(object sender, EventArgs e)
{
numbers = new ArrayList();
LoopPageControls(Page.Controls);
}
private void LoopPageControls(ControlCollection controlCollection)
{
foreach (Control control in controlCollection)
{
if (control.Controls != null)
{
LoopPageControls(control.Controls);
}
else
{
numbers.Add(control.ID);
//LoopPageControls(control.Parent.Controls);
}
}
}
|
|
|
|
|
You need to try following code for the same..
private void ListControlCollections()
{
ArrayList controlList = new ArrayList();
AddControls(Page.Controls,controlList);
foreach (string str in controlList)
{
Response.Write(str + "<br/>");
}
Response.Write("Total Controls:" + controlList.Count);
}
private void AddControls(ControlCollection page,ArrayList controlList)
{
foreach (Control c in page)
{
if (c.ID != null)
{
controlList.Add(c.ID);
}
if(c.HasControls())
{
AddControls(c.Controls, controlList);
}
}
}
//OUTPUT of Code
form1
Panel1
Label1
TextBox1
Label2
TextBox2
Label3
TextBox3
Label10
TextBox10
Label11
TextBox11
Label12
TextBox12
btnControls
lblResult
Total Controls:16
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Thanks Jinal ,
i will try it now and tell you the result . it is a great thing to ask a question and many people from different counties answer you you teach me a new thing today.
thanks agin
Eslam Soliman Adam
|
|
|
|
|
hello again i try jinal code it's perfect and more than that but i want to put this functions in a master page and when i put it it count the control of the master page,which i don't want i want it just to count the controls in the place holder of the master page
thanks
|
|
|
|
|
|
first ,Thanks sandeep i will try it .second ,i have tried a new way you may want to look at it :
public partial class _Default : System.Web.UI.Page
{
ArrayList ar;
protected void Page_Load(object sender, EventArgs e)
{
ar = new ArrayList();
Control[] ControlArray = GetControls(Page.Controls, ref ar);
}
private Control[] GetControls(ControlCollection parent, ref ArrayList controls)
{
foreach (Control c in parent)
{
controls.Add(c);
if ((c.Controls.Count > 0) )
{
GetControls(c.Controls, ref controls);
}
}
return (Control[])controls.ToArray(typeof(Control));
}
}
but it gave me the controls and the literal controls also
system.web.ui.literalcontrol
try it and tell me is it good or not .
thanks agin
|
|
|
|
|
Please format your question so that it is easy to read. There are link like "code block" and "inline code". Please use them wherever appropriate.
|
|
|
|
|
Is it possible to use Response.Redirect after Response.Flush() has been called.
I am using an HttpModule, which is configured with a custom response filter to capture
the HTML output. This filter redirects depending upon detection of certain pattern in the HTML output.
It used to work fine. One day I tried calling Response.Flush() in one of the requested ASP.NET pages.
While redirecting in the filter, it gave the below error.
Cannot redirect after HTTP headers have been sent.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.Web.HttpException: Cannot redirect after HTTP headers have been sent.
After some amount of research, i found that, redirection cannot be done after response has been committed.
This also happens in case of J2EE applications. But that behaviour can be controlled by using wrappers..
Later I found that ASP.NET also has some wrappers. But I was not able to achieve what I was trying.
Is it possible to change the default behaviour by usage of wrappers?. What I mean is to prevent the
response from being sent to the browser, so that I can perform redirection.
I am using Visual Studio Express 2010 with .net framework 4.0
Regards,
Sachin
modified on Thursday, June 17, 2010 1:40 AM
|
|
|
|
|
Hi ,
Might be a simple fix, but struggling for a long time.
I have built a new site and configured that in IIS, whenever I login to the server I get the "Connect to" windows login dialog. However on pressing cancel in this dialog, te screen loads without any issues.
Any idea how i can get rid of this?
Jack Sparrow
--------------------------------------
Defeat is not the worst of failures. Not to have tried is the true failure.
|
|
|
|
|
You need to disable the basic authentication. Look at this[^].
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
If you want to use Windows Authentication then set that Authentication type only in IIS. You need to configure that. By default even Anonymous access are also allowed.
|
|
|
|
|
Hi,
I'm getting a "Mailbox unavailable. The server response was: 5.7.1 <blakepell@gmail.com>... Relaying denied." when I try to route mail outside of my domain. All mail works when I send inside of my domain. Here's the code snippet I'm using:
Dim SmtpMail As New System.Net.Mail.SmtpClient
SmtpMail.Host = _mailServer
SmtpMail.Port = _portnumber
SmtpMail.Send(objMail)
Please help me to resolve this problem...?
With Regards,
Samson
|
|
|
|
|
Use a different SMTP server. The SMTP server you use does not allow relaying. You may want to use the smtp server of your ISP...
|
|
|
|
|
Hi guys,
I have a bit of an issue...
I have say 10 machines sitting behind a router at a remote location.
Each client connects to the same web app - BUT - I want to customize what each client sees as a homepage based on its computername, as in a unique home page for each specific machine (since I cant get IP due to router/firewall/proxy etc.)
Has anyone ever done this? What is the correct way? I have tried with many different techniques, but there are always issues with cross-domain access and local computer access.
Any ideas would be much appreciated!
Thanks.
Xav.
|
|
|
|
|
I have created fusion charts in MVC. Now after clicking on a dataplot in chart, i want to create another new chart. On the fusion chart its given that we can use "FCClickEvent" event. I want to know to is it possible in mvc and if yes then how to add mxml and mx action script.
Please guide me a bit
Thanks
|
|
|
|
|
suppose when i will use ajax in my web apps then i need to monitor how much data is sending to server when partial postback happen. so please tell me is there any tool or best way out.
tbhattacharjee
|
|
|
|
|
You could actually check the fiddler statistics for the amount of data posted and retrieved in each request and response..
Fiddler[^]
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
Is there any method for making a field in Excel as Text field while exporting in asp.net
Known is a drop, unknown is an ocean
|
|
|
|
|
Hi
I want to show some image while sorting the gridview.
Like for ascending show one image,decending show another image.
Same for child gridview also.
Here is the Link for Sample Code
<a href="http://beta.codeproject.com/KB/webforms/EditNestedGridView.aspx?msg=3107070">http://beta.codeproject.com/KB/webforms/EditNestedGridView.aspx?msg=3107070</a>[<a href="http://beta.codeproject.com/KB/webforms/EditNestedGridView.aspx?msg=3107070" target="_blank" title="New Window">^</a>]
have any idea, please let me know.
Regards,
Pawan.
|
|
|
|
|
In my development environment, I've used ASP.NET to create a solution that has two projects: my ASP.NET application and an ASP.NET Web Service. It runs fine in my development environment.
I have a test environment that is on a totally different network than my development environment (they cannot connect to each other). I need to distribute my application, plus my web service on that development environment but haven't been able to figure out how to get my application to access the web service.
I'd like to do this without having to modify my application to redirect access to the web service every time I build it and copy it to the test environment.
This is for an intranet so I'm not going to publish the web service on the internet.
Any help would be greatly appreciated.
|
|
|
|
|
Have a look at this[^].
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Hi,
I am referncing a Amazon S3 web service, We have access key and secret key.
I want to put a file in the bucket, buckets are created thro' UI
AmazonS3.PutObjectResult myResult = amazonwsObject.PutObjectInline(BucketName, secretKey, metadata, Filedata, contentLength, null, AmazonS3.StorageClass.STANDARD, True, APIKey, GetTimeStamp(DateTime.Now), True, sign, null)
I am using Following method to calculate Signature:
public string GetSignature(string mySecretAccessKeyId, string strOperation, DateTime myTime)
{
Text.Encoding myEncoding = new Text.UTF8Encoding();
string mySource = ("AmazonS3" + strOperation) + FormatTimeStamp(myTime);
Security.Cryptography.HMACSHA1 myCrypto = new Security.Cryptography.HMACSHA1(myEncoding.GetBytes(mySecretAccessKeyId));
char[] mySourceArray = mySource.ToCharArray();
byte[] myUTF8Bytes = myEncoding.GetBytes(mySourceArray);
byte[] strDigest = myCrypto.ComputeHash(myUTF8Bytes);
return Convert.ToBase64String(strDigest);
}
I could able to see all the buckets created using the same signing method using ListAllBuckets method.
But for putObjectInline method , I am getting soap Exception "Signatures are not matching"
Can anyone please, help me
Vsaratkar
|
|
|
|
|
Hi,
I have created a site, now I want to upload it on the server. I do not have the experience of uploading the site on server, plz help me in this. I am using ASP.NET C# MySQL.
Thanks
|
|
|
|