|
Sir,
I m adding texbox in grid at runtime . it added successfully
but my problem is that how to read a value in a texbox i m sending
my code plz check this code give me reply
SqlDataAdaptor da=new SqlDataAdaptor("Select * from mytable",MyConnectionString);
DataSet dtSet=new DataSet();
da.Fill(dtSet);
GridView1.DataSource=dtSet.Table[0];
GridView1.DataBind();
TextBox txt ;
string strID;
//Add Textbox in a grid
for (int i = 0; i < dtSet.Tables[0].Rows.Count; i++)
{
for (int j = 0; j < dtSet.Tables[0].Columns.Count; j++)
{
txt = new TextBox();
strID = i.ToString()+j.ToString();
txt.ID=strID;
GridView1.Rows[0].Cells[0].Controls.Add(txt);
}
}
//Read This TextBox Value
string strTextID;
for (int i = 0; i <GridView1.Rows.Count ; i++)
{
for(int j=0;j<GridView1.Columns.Count;j++)
{
strTextID=i.ToString()+j.ToString();
TextBox txt = (TextBox)GridView1.Rows[i].Cells[j].FindControl(strTextID);
string strText=Txt.Text;//This Statement Give me error
}
}
plz send me reply
Thanks & Regards
Lav Naphade
lav naphade
|
|
|
|
|
|
sir,
my problem is my gridview column size is not fix so i can not
add column in a template control so adding textbox in a grid at
run time .
how to add textbox in a ItemTemplate at runtime or template controlt?
plz sir give me proper solution .
lav naphade
|
|
|
|
|
To add the control you should be using the RowDataBound event (http://msdn2.microsoft.com/en-us/library/system.web.ui.webcontrols.gridview.rowdatabound.aspx[^]) like this:
<br />
protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e){<br />
if(e.Row.RowType == RowType.DataRow){<br />
txt = new TextBox();<br />
strID = "textBox1";<br />
txt.ID=strID; <br />
<br />
e.Row.Cells(1).Controls.Add(txt)<br />
}<br />
}<br />
Try recursively searching the result of : GridView1.Rows[i].Cells[j]. Instead of calling
GridView1.Rows[i].Cells[j].FindControl(strTextId). Do a recursive search of each of the child controls like this:
<br />
Control ctrl = GridView1.Rows[i].Cells[j];<br />
<br />
TextBox txt = FindControlRecursive(ctrl, strTextId) as TextBox;<br />
if(txt != null){<br />
}<br />
Where your recursive function looks like this:
<br />
private Control FindControlRecursive(Control current, String textId){<br />
Control result = current.FindControl(textId);<br />
if(result != null)<br />
return result;<br />
<br />
foreach(Control ctrl in current.Controls){<br />
result = FindControlRecursive(ctrl, textId)<br />
if(result != null)<br />
return result;<br />
}<br />
<br />
return null;<br />
}<br />
|
|
|
|
|
I nested a repeater inside a gridview templateField, this works fine, the problem is now the gridview width will not expand when the page is expanded.
Prior to this I had nested gridviews and the parent gridview's width expanded with the page. Is there a workaround to get the parent grid to expand with a nested repeater?
|
|
|
|
|
Hello everybody,
I read the excellent article about inserting a captcha control in a webpage, located here[^].
I liked so much the idea, that I wanted to extend the standard Login webcontrol which comes with ASP.NET 2.0, by adding a captcha image to be read and its content typed into a textbox.
The solution I found in the article uses the Page Session to generate an unique ID, that is then compared to what the user types.
My problem is that when I try to implement the very same solution in the webcontrol, I cannot access the Page object at all! It's like I cannot retrieve the page object my new webcontrol refers to, from within the control itself.
Is there some workaround to access the Page property?
If not, what could I use to generate an unique ID to be compared? I was thinking of simply generating a random number, but I do not know if it's recommendable.
Thanks in advance
Rey9999
~~~ From Milano to The Hague, easy as it goes ~~~
|
|
|
|
|
Rather than creating your own user control, couldn't use the login control template to include the captcha?
only two letters away from being an asset
|
|
|
|
|
I could.. but you know, this was not something I needed done for work, it was just to see if I were still able to extend existing cotrols. I liked the "login+captcha" idea, that's all. Anyway, I went with the random number approach, not so elegant but it works.
Now I have another problem:
How can I tell the control that it first has to check the correctness of the captcha?
I tried overriding the event OnLoggingIn, but this seems to happen when the login has already taken place.
Any ideas?
Thanks in advance
Rey9999
~~~ From Milano to The Hague, easy as it goes ~~~
|
|
|
|
|
The random number approach is a failure: since the page seems to reload the control after the loggingin procedure, I cannot have a unique identifier for each login attempt, beside the page session.
But how can I access it from the webcontrol itself?
Any help would be much appreciated. Thank you.
Rey9999
~~~ From Milano to The Hague, easy as it goes ~~~
|
|
|
|
|
Hi, I would like to ask for help for one simple issue. I am a beginner in ASP.NEt and I would like to put the data from the textbox in database. So, I have a textbox and a button and a Sql Server DB, and I tried different things but nothing didn't work. I would really like to know how this simple thing is going, and I know that it can be done for 5 min, so if some one have a spare 5 min to spend on that kind of project, and attach a source code from the project, I would really appreciated. Thanks ahead
|
|
|
|
|
have you created any code yet, can we see it?
this is an example using stored procedure:
SqlCommand cmd_insertintotable = new SqlCommand("insertintotable", con4);
cmd_insertintotable.CommandType = CommandType.StoredProcedure;
cmd_insertintotable.ExecuteNonQuery();
cmd_insertintotable.Parameters.Add(new SqlParameter("@textboxvalue", SqlDbType.VarChar));
cmd_insertintotable.Parameters["@textboxvaluecode"].Value = textboxvalue.text;
here is the actual stored procedure which you should have in sql server:
CREATE Procedure insertintotable
(
@field varchar (30),
)
AS
INSERT INTO table
(field )
VALUES
(@textboxvalue)
this should get you going, remember you need an sql connection as well but you can do some work!
|
|
|
|
|
.netman wrote: CREATE Procedure insertintotable
(
@field varchar (30),
)
AS
INSERT INTO table
(field )
VALUES
(@textboxvalue)
that should be
CREATE Procedure insertintotable
(
@textboxvalue varchar (30)
)
AS
INSERT INTO table
(field )
VALUES
(@textboxvalue)
|
|
|
|
|
Hi,
I'm using ASP.NET 2.0 C# on a website with some pages using HTTPS with an SSL cert from VeriSign. The C# redirects any required page to use HTTPS.
However in Firefox I get the "Connection Partially Encrypted" warning and padlock with line through it and IE gives the "This page contains unencrypted items" warning.
As far as I can see it the generated link WebResource.axd that is not going through the SSL as its jumping to the root with no https reference:
Disabling Javascript on the Browser allows the page to become fully
secure (no red line in the padlock).
Any ideas of how to prevent this as it now appears our site is not secure despinte having an expensive certificate?
Sam
modified on Friday, March 28, 2008 11:35 AM
|
|
|
|
|
Hi,
I have a website developed using Forms Authentication with the SqlMembershipProvider.
The host has set Medium Trust Level, which results in reflection being disabled.
When I access the page that has the login control, I get the following security exception:
System.Security.SecurityException: Request for the permission of type 'System.Security.Permissions.ReflectionPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
I have dug into some information about forms authentication in ASP.NET 2.0, and as far as I can find out, forms authentication uses reflection to determine the provider to use.
The website is currently running on a webserver that does allow reflection, but I have to move to another provider because of several issues. Almost every hosting provider uses the medium trust level on their shared services. We do not want a dedicated server (too expensive and not necessary).
This is a snippet from the web.config where I set the membership provider and the profile.
<membership defaultProvider="ArtistSqlMembershipProvider" userIsOnlineTimeWindow="30"><br />
<providers><br />
<remove name="AspNetSqlMembershipProvider"/><br />
<add name="ArtistSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="LocalSqlServer" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" applicationName="/" requiresUniqueEmail="true" passwordFormat="Hashed" maxInvalidPasswordAttempts="3" minRequiredPasswordLength="4" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="30" passwordStrengthRegularExpression=""/><br />
</providers><br />
</membership><br />
<profile defaultProvider="AspNetSqlProfileProvider"><br />
<properties><br />
<group name="Personal"><br />
<add name="FullName" type="System.String" serializeAs="String" allowAnonymous="false"/><br />
<add name="AddressLine1" type="System.String" serializeAs="String" allowAnonymous="false"/><br />
<add name="AddressLine2" type="System.String" serializeAs="String" allowAnonymous="false"/><br />
<add name="AddressLine3" type="System.String" serializeAs="String" allowAnonymous="false"/><br />
<add name="Country" type="System.String" serializeAs="String" allowAnonymous="false"/><br />
<add name="PhoneNumber" type="System.String" serializeAs="String" allowAnonymous="false"/><br />
</group><br />
<group name="Privacy"><br />
<add name="ShowEmail" type="bool" serializeAs="Binary" allowAnonymous="false"/><br />
<add name="ShowAddress" type="bool" serializeAs="Binary" allowAnonymous="false"/><br />
<add name="ShowPhoneNumber" type="bool" serializeAs="Binary" allowAnonymous="false"/><br />
</group><br />
<group name="Authorization"><br />
<add name="AdminRights" type="System.Collections.Specialized.StringCollection" serializeAs="Binary" allowAnonymous="false"/><br />
</group><br />
<group name="Activity"><br />
<add name="AdminCurrentVisit" type="System.DateTime" serializeAs="String" allowAnonymous="false"/><br />
<add name="AdminPreviousVisit" type="System.DateTime" serializeAs="String" allowAnonymous="false"/><br />
<add name="PublicCurrentVisit" type="System.DateTime" serializeAs="String" allowAnonymous="false"/><br />
<add name="PublicPreviousVisit" type="System.DateTime" serializeAs="String" allowAnonymous="false"/><br />
<add name="IPAddresses" type="System.Collections.Specialized.StringCollection" serializeAs="Binary" allowAnonymous="false"/><br />
</group><br />
<group name="Notification"><br />
<add name="TradesSalesDigest" type="bool" serializeAs="Binary" allowAnonymous="false"/><br />
<add name="ForumDigest" type="bool" serializeAs="Binary" allowAnonymous="false"/><br />
</group><br />
</properties><br />
</profile><br />
How can I resolve this?? Should I use another way of providing the forms authentication (and thus write the entire handling of the users myself)?? Can I come around the reflection another way??
modified on Sunday, March 30, 2008 5:33 AM
|
|
|
|
|
I have a web app that runs a bunch of SSRS reports in the background, i settled on running each reports (up to 30 ata time ) on different threads, and it runs lightning fast, generating all of them almost simultaneously. Then i was asked to display the results (namely success or failure, and if failure, what caused it) to the page. my question is, is it possible, and if so how do I write the results from the threads to a page while they run.
I have run loops in the past and used Response.Flush() after Response.Write() to display the results, but things start to get hairy when using multiple threads.
Any ideas?
______________________
Mr Griffin, eleventy billion is not a number...
|
|
|
|
|
Well I think the first thing to do is to synchronize the output. I assume you some class that is controlling all the threads. This class should compile the results. Then your page can get the information through a web service you call client side. You can use the output to update your we b page. Or perhaps another option would be to implement the ICallbackEventHandler interface and have some client side code on a timer.
modified on Friday, March 28, 2008 12:07 PM
|
|
|
|
|
Hello ,
I want to know how can I make a call to a webmethod with a private key and certificate. I mean the server expect the webmethod to send messagedigest with the web method call.
Please suggest.
Regards,
Pavas
|
|
|
|
|
In my Web.config file,authentication mode is "Form" and login url is "Login.aspx" which is in root directory.when i am calling a page which is in sub directory,then my page should automatically redirect to "Login.aspx" for authentication.but my problem is that instead of redirecting the page to "login.aspx" in root directory it searches in the same sub directory hence it does not get a file.
But when i am working offline ie on local PC,i don't get this problem.when i have uploaded this project on server i face this problem. Thank u.
coolsatty
|
|
|
|
|
I think you may need to specify the entire path of where your login.aspx page is rather then just ~/login.aspx
|
|
|
|
|
I tried putting entire path but it still searches in sub directory.Is there any settings in IIS because here in my PC its working fine but at server(handled by third party)side i am getting this problem.
coolsatty
|
|
|
|
|
I believe your problem is a result of your file path being relative. Ensure that your configuration references the file from the website root. In your case, ~/login.aspx should work.
Hope that helps.
--Jesse "... the internet's just a big porn library with some useful articles stuck in." - Rob Rodi
|
|
|
|
|
Hi,
Try "~/Login.aspx".
Faraz Shah Khan
MCP, MCAD.Net
Blog
|
|
|
|
|
tried it but still the same problem.
coolsatty
|
|
|
|
|
Hi,
this is from my project
<authentication mode="Forms">
<forms name=".ASPXFORUM" loginUrl="~/index.aspx" protection="All" timeout="180" path="/"/>
</authentication> and it works absolutely fine with me.
Faraz Shah Khan
MCP, MCAD.Net
Blog
|
|
|
|
|
hi,
this is my code for uploading the file on server :
protected void Button1_Click(object sender, EventArgs e)<br />
{<br />
<br />
string savepath = @"ftp://66.197.198.204/ansarishan.somee.com/";<br />
if (FileUpload1.HasFile)<br />
{<br />
string filename = FileUpload1.FileName;<br />
savepath += filename;<br />
Label3.Text = "Your File has Upload as" + "" + filename;<br />
FileUpload1.SaveAs(savepath);<br />
}<br />
else<br />
{<br />
Label3.Text = "You Did not Specify a File To Upload";<br />
}<br />
}
But when i try to upload any file then an exception raise :
The SaveAs method is configured to require a rooted path, and the path 'ftp://66.197.198.204/ansarishan.somee.com/Winter.jpg' is not rooted.
although i can drag/drop files on "ftp://66.197.198.204/ansarishan.somee.com/" manually
what is the meaning of "rooted path"?
where is problem ?
|
|
|
|