|
Hey man
I have given you the line how to get a control from code behind, but here is the line to commit data back to a control from code behind. This example sets the text of a text box inside the createuserwizard in the aspx page using a code behind command:
CType(Me.CreateUserWizardStep1.ContentTemplateContainer.FindControl("AllowNext"), TextBox).Text = String
Hope those help. Check out the previous thread where i was having the same prob for greater detail.
Cheers dev
|
|
|
|
|
I was also able to commit data back to a label by making it equal to the asp.net label first. (My grasp of these things is more limited than I'd like, but I think this is an alternate method.)
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs)
Dim TextBoxOne As TextBox = Me.Test.ContentTemplateContainer.FindControl("TextBox1")
Dim TextBoxTwo As TextBox = Me.Test.ContentTemplateContainer.FindControl("TextBox2")
Dim LabelOne As Label = Me.Test.ContentTemplateContainer.FindControl("Label1")
LabelOne.Text = (CDbl(TextBoxOne.Text) + CDbl(TextBoxTwo.Text))
End Sub
Thanks Again,
JTok
|
|
|
|
|
Hi there
I've been working on this problem for ages now and it makes no sense. I have a create user wizard and wish to put variable within it, the problem is that i cannot for some reason see these variables from the code behind file. Below is a basic example of the aspx file:
<asp:CreateUserWizard runat="server" ID="CreateUserWizard1" AutoGeneratePassword="False"
ContinueDestinationPageUrl="../GeneralForms/Default.aspx" FinishDestinationPageUrl="../GeneralForms/Default.aspx">
<WizardSteps>
<asp:CreateUserWizardStep ID="CreateUserWizardStep1" runat="server">
<ContentTemplate>
<b><asp:textbox runat="server" id="txtTest"/></b>
</ContentTemplate>
</asp:CreateUserWizardStep>
</WizardSteps>
</CreateUserWizard>
Now the bolded text box for some reason cannot be seen by this web pages code behind file. Does anyone know why or have a solution.
Thank you so much in advance for any help. I'm going CrAzY!!
Devin
|
|
|
|
|
When a control is inside a template, like the wizard template, or the columns of a gridview, the control that contains it, often creates it many times. Therefore, it's not visible in the code behind, because it may not be a single control. You have to interact with the wizard control itself, perhaps with the findcontrol method, to find the controls that are inside the wizard control, but, ideally, each contenttemplate should be a single control, which, in itself, interacts with all it's controls in whatever way it needs to, to work properly.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi there
Sorry to be an inconvenience, but would u mind popping my code i write into a blank aspx page, and see if u can get to the control placed in it. As i have tried to do your suggested method prior to posting and to no avial. Maybe should u be able to find the control then i could c the long command u used to do so.
Thanks again for any assistance. Nearly 5 hours gone and im still battling...
Dev
|
|
|
|
|
To be honest, I've never used the wizard control, but I recognise the problem, having dealt with it using templated controls. Using the grid view, when I work on a specific row, I get given the row, and I can call the FindControl method to find the instance of the control in the row.
Why do you need to access the control ? Is there no way you can make the control self contained ? If your control has events, you can hook those to methods in the main page using the aspx.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hey Christian
Well i'm trying to include a CAPTCHA into the signup process before user is committed to the database, and thus need to include it in this step. However since your last post i have made ground throught the line:
Dim CodeTextBox As TextBox = Me.CreateUserWizardStep1.ContentTemplateContainer.FindControl("CodeTextBox")
This has allowed me to get values of controls within the page! YEY But now my problem is im trying to find the command to set values back into the controls on the page. Any ideas on this one?
Thanks again for the help...
|
|
|
|
|
SOLVED!!! YIPEE
Here's the line to send something back into a web control programatically. The example im pasting sets the text string for a textbox control programatically. While in the previous post is pasted the line to get a web control from code behind if its hidden.
CType(Me.CreateUserWizardStep1.ContentTemplateContainer.FindControl("AllowNext"), TextBox).Text = ToString
This is just incase anyone is suffering the same problem i have endured! Hope it helps...
Cheers
Dev
|
|
|
|
|
I would like to create a data grid that has a column, where in a given row, there is sometimes a button and sometimes plain text. (The decision between button\text will be based on the string in the column of the given row.)
Can this be done? What type of column should I use?
DWreck
Dwreck
|
|
|
|
|
One solution would be to have both the button and text controls in a TemplateColumn, and set the Visible property of each control depending on the value of your string in the ItemDataBound event.
- S
50 cups of coffee and you know it's on!
|
|
|
|
|
Hi,
Does anyone know what this following regular expression would interpret as?
Regex re=new Regex("((?<field>[^\",\\r\\n]*)|\"(?<field>([^\"]|\"\")*)\")(,|(?<rowbreak>\\r\\n|\\n|$))");
Many thanks for your time.
|
|
|
|
|
((?[^\",\\r\\n]*)|\"(?([^\"]|\"\")*)\")(,|(?<rowbreak>\\r\\n|\\n|$))
Basically (...)s create a group which can be retrieved later from the results if it has a (?...) then it is simply used as grouping in the regex and is not output to the results.
Pattern 1: The 1st bracket then is looking any characters bar for a quote (") followed by a comma (,) and carriage return / line feed (\r\n). It wants one or more of these consecutively.
Pattern 2: The 2nd bracket is looking for any characters except a quote or a two quotes, again matching zero or more of these consecutively.
Pattern 3: The 3rd bracket(s) are looking for a comma or (a carriage return, line feed or a new line or the end of the string).
So in summary it's matching Pattern 1 or a quote followed by Pattern 2 and 3.
Hope that explains it a bit, it's quite difficult to put into words, just remember that brackets act like grouping constructs like in any programming language, except here unless they have a ? following the opening parenthesis (? then the group is output into the results.
|
|
|
|
|
It is comma delimited csv file that is being read. To change the comma to a tilda(~) delimited file, would changing in those two places a comma occurs to tilda work?
Thanks.
|
|
|
|
|
Hi everyone:
I'm new in .net web programming, and I really need help on this, because i have to finish this work by next week, and by now, I am getting desperate!!!! My issue is that I have a web site, kind of a point of sale (POS), but I need users to print tickets on their local printers. I dont know how to do this, since my app doesn't "see" any network printer. I am printing directly to the printer, not using any reports. Please I would really appreciate any solution, even any suggestion on how to make it better. Thanks in advance...
|
|
|
|
|
Just generate a simple HTML "report" and then you can use javascript or tell them to print the page themselves. That's what everyone else does.
|
|
|
|
|
You can't see their printer, you can't see anything on their PC. You can give them a form to print, but you can't know they will print it, or even that they have a printer.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
I have two apsx pages. In the first aspx page I have one gridView and a linkbutton under gridview. When the user clicks on LinkButton it will take you to the next aspx page. In the second aspx page I have 2 text boxes and one button Insert. The user enter some data into text boxes and clicking on Insert button will take him to the first aspx page and fill the textboxes data to Gridview.
In the first aspx page my code is like this:
Page_Load()
{
GridView1.DataSource = (System.Data.DataTable)Session["dta"];
GridView1.DataBind();
dta = (System.Data.DataTable)CreateDataTableA();
if (!IsPostBack)
{
Session["dta"] = dta;
}
}
//This is for link button click event.
protected void LBAddPartner_Click(object sender, EventArgs e)
{
Response.Redirect("PartnerDistrict.aspx");
}
protected System.Data.DataTable CreateDataTableA()
{
System.Data.DataTable aTable = new System.Data.DataTable();
DataColumn dtCol;
// Create ID column and add to the DataTable.
dtCol = new DataColumn();
dtCol.DataType = System.Type.GetType("System.String");
dtCol.ColumnName = "District_ID";
dtCol.AutoIncrement = false;
dtCol.Caption = "District_ID";
dtCol.ReadOnly = false;
dtCol.Unique = false;
// Add the column to the DataColumnCollection.
aTable.Columns.Add(dtCol);
// Create Name column and add to the table
dtCol = new DataColumn();
dtCol.DataType = System.Type.GetType("System.String");
dtCol.ColumnName = "District_Name";
dtCol.AutoIncrement = false;
dtCol.Caption = "District_Name";
dtCol.ReadOnly = false;
dtCol.Unique = false;
aTable.Columns.Add(dtCol);
return aTable;
}
In the second page:
//Insert button click:
protected void Button1_Click(object sender, EventArgs e)
{
dta = (System.Data.DataTable)Session["dta"];
DataRow dr = dta.NewRow();
dr[0] = txtboxDID.Text.ToString();
dr[1] = txtBoxDName.Text.ToString();
dta.Rows.Add(dr);
//Response.Redirect("Default.aspx");
Response.Redirect("Default.aspx");
txtboxDID.Text = "";
txtBoxDName.Text = "";
}
My problem is I the gridview (datatable) showing only the last inserted record only . WhereI mean in which event I have to put this line Session["dta"]=dta in first aspx page to persist all records.
Thanks in advance
|
|
|
|
|
The line doesn't matter, if it's in the session, it's in the session. If the data comes from your database, a better solution is to pass over an Id which can be used to reproduce the database query to get the data down again on your new page. Another option is cross page postback, and pulling the data out of viewstate.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Any ever have any trouble using an updatePanel with RadioButtonLists? I am getting it to update once without posting back to the server using async postback but once I click on the other radiobutton it doesn't run the same set of code again. If you know of any articles to read that would be great!
Thanks,
Cisco
|
|
|
|
|
I am building datasets at run time from asn asp.net c# web page. My chalenge is one of my stored proceedures has to harvest an extremely large dataset depending on the date range selected. My question is how to I set the progress of the stored proceedure?
Here is a scenario
if the data range is this month or this week the proceedure will run in a small period of time maybe 15 seconds. But if they choose to run the dataset going back one full year then it will take atleast 5 mins to generate the appropriate data.
How to I make the asp.net webpage wait until that proceedure is done?
Thanks
|
|
|
|
|
wait how ? Your page is going to timeout in five minutes. Your best bet is to have another process, such as a windows service, do the stored proc call, and have your page auto postback, or use AJAX, to work out when the process has ended, and the data can be loaded by the page.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi,
I added an attribute to the items of a DropDownList.
cbBudget.Items(0).Attributes.Add("bLocked", true)
cbBudget.Items(1).Attributes.Add("bLocked", false)
Now I want to get the value of the selected item in the DropDownList using javascript.
I tried something like this:
document.getElementById("cbBudget").selectedItem.getAttribute("bLocked")
but it doesn't work.
The source looks like this:
Class1
Class 2
Thank you for your suggestions.
|
|
|
|
|
|
This also worked
var index =document.getElementById("cbBudget").selectedIndex;
alert(document.getElementById("cbBudget").options[index].bLocked)
Thanks Ben
|
|
|
|
|
Thanks Ben,
That is a great article, now I don't have to Alert("I am here"); anymore.
Martin
|
|
|
|