|
I've created a literal for each of my text snippets (<asp:literal id="ABCDUnique">blah blah blah). I have other literals that are updated based on code execution, so that is the reason all literals start with ABCD.
In Page_Load, I do something like:
string pageName = "UniqueName";
languageCode = 1;
TranslateControls(pageName, this.Controls);
I then define the TranslateControls method as:
private void TranslateControls(string pageName, ControlCollection controls)
{
for (int i=0; i < controls.Count; i++)
{
Control ctrl = controls[i];
if (ctrl.HasControls())
{
TranslateControls(pageName, ctrl.Controls);
}
else
{
if (ctrl.GetType() == typeof(System.Web.UI.WebControls.Literal))
{
if (ctrl.UniqueID.StartsWith("ABCD"))
{
Literal litTemp = (Literal)ctrl;
Database db = new Database();
string textTranslation = db.GetText(pageName, ctrl.UniqueID, languageCode);
litTemp.Text = textTranslation;
}
}
}
}
}
Problem is, some controls are ignored -- when logging/stepping through, it appears that they are not part of the ControlCollection. Any thoughts/ideas?
-- modification
When page is initially loaded, all controls are displayed properly. However, on postback, some controls are missed and appear blank (odd, as they have initial text, and the db.GetText method returns either valid text or ctrl.UniqueID surrounded by underscores).
-- end modification
Thanks,
Glenn
-- modified at 16:07 Wednesday 25th April, 2007
|
|
|
|
|
Delete else please.This is a logical error.
|
|
|
|
|
Even with the else removed, the literals do not appear.
|
|
|
|
|
Glenn E. Lanier II wrote:
When page is initially loaded, all controls are displayed properly. However, on postback, some controls are missed and appear blank (odd, as they have initial text, and the db.GetText method returns either valid text or ctrl.UniqueID surrounded by underscores).
Knowing this bit had something to do with it, after much head-banging/debugging, I realized that my literal was not listed in the .cs file.
My non-required fields displayed, as they are defined:
<label for="txtBillFirstName"><asp:label id="lblBillFirstName" runat="server"><asp:literal runat="server" id="litTextBillNameFirst">First Name:</asp:literal></asp:label></label><br />
but the [initially] required fields were not, defined as:
<label for="txtBillFirstName"><asp:label id="lblBillFirstName" runat="server">* <asp:literal runat="server" id="litTextBillNameFirst">First Name:</asp:literal></asp:label></label>
Apparently, you can have an asp:literal in an asp:label if it is the only thing in the label, but mixing text with a literal doesn't appear to work.
The initial text displayed on the page load, but not on a postback - not sure why even the * didn't show up. Some of the fields are only required based on selections made on the form, so if I cause the error conditions, those labels displayed as required, which threw me off track a little.
--G
-- modified at 12:41 Thursday 26th April, 2007
|
|
|
|
|
hii,
i want to create a webform in the runtime. it is something like a tool to build a web form?
do u have any ideaies?
thanks
|
|
|
|
|
One Idea!!!
How bout if you use XML and XSLT
Create xml after reading the tables in database you might be bulding forms upon
and then convert xml by using xslt?
If not depending on tables on database just make some rules to create xml which
will represent a form and then convert that through xslt?
What do you think?
|
|
|
|
|
Hi
I have 2 Textboxes I need to compare the value of the 2 Textboxes I have a method it is working fine .But When I enter the Space it is giving error.
So pls provide me solution this is very urgent.
Thanks,
|
|
|
|
|
user this trim function for doing trim operation
function trim(str)
{
str.replace(/^\s+/,'').replace(/\s+$/,'');
}
usage
trim(document.forms[0].textbox1.value)
-- modified at 9:22 Thursday 5th July, 2007
|
|
|
|
|
Hello,
I have created a GridView on runtime by implementing the ITemplate class.
This Gridview displays a list of articles. Each article has a Title, Content and PubDate.
I am trying to create a Date Header like in a blog, i.e., display the date on top of every daily posts.
For example:
Wednesday, 25 of April of 2007
Article 3 (PubDate: 25.04.2007 # 20:15)
Article 2 (PubDate: 25.04.2007 # 11:30)
Article 1 (PubDate: 25.04.2007 # 08:40)
Wednesday, 24 of April of 2007
Article 2 (PubDate: 24.04.2007 # 21:32)
Article 1 (PubDate: 24.04.2007 # 15:45)
How can I created the date header as I described?
Thanks,
Miguel
|
|
|
|
|
I have a table with two columns
AppName AppLocation
TestApp1 folder1
TestApp2 folder2
TestApp3 folder3
TestApp4 folder4
TestApp5 folder5
I have to shows data of column AppName as hyperlink and when I click on hyperlink
TestApp1 it should navigate to second column and go to folder1 in which I have
test1.aspx page. It should open that page.
So Far I made a gridview and set one column as hyperlink. I bound the data with this gridview.
I set the column property
DataTextField = AppName and DataNavigateUrlFields = AppLocation.
But it is not opening test1.aspx page which is in folder1 or folder2 or so on.
How can I fix this problem.
Thanks in advance
|
|
|
|
|
Hi,
R u using <asp:HyperLink> control in the gridview. If yes then did u set the "NavigageUrl" proprty of that?
Thanks and Regards,
Chetan Ranpariya
|
|
|
|
|
hi all
i have a dropdownlist in datagrid and have to populate it data in pageload along with grid.later i have to fire the ddlselectedindex when it is in grid
|
|
|
|
|
Use the gridview's RowCreated Event.I just write a example and tested it:
protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
{
GridView g = (GridView)sender;
if (g.Rows.Count == 0)
{
return;
}
DropDownList ddl = (DropDownList)g.Rows[g.Rows.Count-1].FindControl("ddl");
if (ddl != null)
{
object[] array = new object[] { DateTime.Now.ToString() };
ddl.DataSource = array;
ddl.DataBind();
}
}
When you get ddl you can do it yourself.
|
|
|
|
|
I've forgotten to remind you that ddl is the DropDownList's id in the GridView.
|
|
|
|
|
Hi friends
how to create online quiz in asp,c#.net
can u help me????
regards
saravanan
|
|
|
|
|
saravanan05 wrote: how to create online quiz in asp,c#.net
as it's so general...so...just give you idea...
- display questions on web page (if so manay questions,...consider using paging)
- have Next button to allow user to move next question page
- all user's answers maybe stored in session
- when ending the quiz, calculate the number of correct/wrong answers
Hope you get the idea...Try and post specific questions here if any problem
<< >>
|
|
|
|
|
saravanan05 wrote: how to create online quiz in asp,c#.net
Create a database with questions and answers.
Display the questions randomly on the page
Accept the answers and check them
Keep a score.
If you want a more specific answer, then you'll really have to ask a more specific question.
|
|
|
|
|
Hi,
I am trying to use RSACryptoServiceProvider in my ASP.NET application to access keys from a MachineKeyStore on my computer, running windows xp and IIS 5.
I created machinekeystore like following in Visual Studio 2005 Command Prompt:
aspnet_regiis -pc "CustomKeys" -exp (command was successful)
Then I executed following command because I am impersonating my web application with a non-default user:
aspnet_regiis -pa "CustomKeys" "domain\auserforapplication" (command was successful)
Then I worte the following code:
public partial class Examples_EncryptionExample : System.Web.UI.Page<br />
{<br />
CspParameters CspParam;<br />
string publicXmlString = string.Empty;<br />
string privateXmlString = string.Empty;<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
try<br />
{<br />
byte [] encrypted;<br />
string decrypted;<br />
<br />
UnicodeEncoding ByteConverter = new UnicodeEncoding();<br />
encrypted = EncrptData("data to encrypt");<br />
Response.Write(System.Text.Encoding.Unicode.GetString(encrypted));<br />
decrypted = DecryptData(encrypted);<br />
Response.Write(decrypted);<br />
}<br />
catch (Exception ex)<br />
{<br />
}<br />
}<br />
<br />
public string DecryptData(byte [] data)<br />
{<br />
RSACryptoServiceProvider RsaCsp;<br />
byte[] decryptedData;<br />
RsaCsp = new RSACryptoServiceProvider();<br />
RsaCsp.FromXmlString(privateXmlString);<br />
decryptedData = RsaCsp.Decrypt(data, false);<br />
return System.Text.Encoding.Unicode.GetString(decryptedData);<br />
}<br />
<br />
public byte [] EncrptData(string data)<br />
{<br />
RSACryptoServiceProvider RsaCsp;<br />
RSACryptoServiceProvider RsaCsp2;<br />
UnicodeEncoding ByteConverter = new UnicodeEncoding();<br />
CspParam = new CspParameters();<br />
CspParam.KeyContainerName = "CustomKeys";<br />
CspParam.Flags = CspProviderFlags.UseMachineKeyStore;<br />
<br />
byte[] encryptedData = ByteConverter.GetBytes(data);<br />
<br />
RsaCsp = new RSACryptoServiceProvider(CspParam);<br />
<br />
publicXmlString = RsaCsp.ToXmlString(false);<br />
privateXmlString = RsaCsp.ToXmlString(true);<br />
<br />
RsaCsp2 = new RSACryptoServiceProvider();<br />
RsaCsp2.FromXmlString(publicXmlString);<br />
encryptedData = RsaCsp2.Encrypt(System.Text.Encoding.Unicode.GetBytes(data), false);<br />
<br />
return encryptedData;<br />
}<br />
}
The problem over here is that when ever I try to execute the above mentioned code. Code encrypts the data fine
but when it comes at decrypting the data, throws following exception:
<br />
Exception Details: System.Security.Cryptography.CryptographicException: The system cannot find the file specified.<br />
<br />
<br />
Source Error: <br />
<br />
<br />
Line 35: byte[] decryptedData;<br />
Line 36: RsaCsp = new RSACryptoServiceProvider();<br />
Line 37: RsaCsp.FromXmlString(privateXmlString);<br />
Line 38: decryptedData = RsaCsp.Decrypt(data, false);<br />
Line 39: return System.Text.Encoding.Unicode.GetString(decryptedData);<br />
<br />
<br />
Source File: c:\Data\iis\www\DefaultWeb\Phoenix\Admin\Examples\EncryptionExample.aspx.cs Line: 37 <br />
<br />
Stack Trace: <br />
<br />
<br />
[CryptographicException: The system cannot find the file specified.<br />
]<br />
System.Security.Cryptography.CryptographicException.ThrowCryptogaphicException(Int32 hr) +33<br />
System.Security.Cryptography.Utils._CreateCSP(CspParameters param, Boolean randomKeyContainer, SafeProvHandle& hProv) +0<br />
System.Security.Cryptography.Utils.CreateProvHandle(CspParameters parameters, Boolean randomKeyContainer) +201<br />
System.Security.Cryptography.RSACryptoServiceProvider.ImportParameters(RSAParameters parameters) +262<br />
System.Security.Cryptography.RSA.FromXmlString(String xmlString) +465<br />
Examples_EncryptionExample.DecryptData(Byte[] data) in c:\Data\iis\www\DefaultWeb\Phoenix\Admin\Examples\EncryptionExample.aspx.cs:37<br />
Examples_EncryptionExample.Page_Load(Object sender, EventArgs e) in c:\Data\iis\www\DefaultWeb\Phoenix\Admin\Examples\EncryptionExample.aspx.cs:28<br />
System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +15<br />
System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e) +34<br />
System.Web.UI.Control.OnLoad(EventArgs e) +99<br />
System.Web.UI.Control.LoadRecursive() +47<br />
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1061
I could control the above mentioned error by doing a nasty trick which is. The account "domain\auserforapplication" which I am impersonating my application with. I used a utility in windows xp accessible from "All Programs/Accessories/System Tool/Schedule Tasks" to create a process e.g. executed calc.exe application under the account "domain\auserforapplication". Everything started working fine. No error nothing.
A million dollar question is why did I get the above mentioned error at the first place? Why did I had to start a new process under the indentity of my application on my machine.
If somebody could answer my question. I will highly appreciate that because then I have another question regarding exporting the keys to Windows 2003 Server and using keys over there. That problem is even more nasty.
For now I will highly appriciate if somebody could answer my current question.
Thanks
|
|
|
|
|
Hi,
I have a ascx page ItemEdit.ascx. It contains a combobox. This control dynamically added to a aspx page.
Now the problem is that i am unable to catch the event(selectedindexchange)of combobox in ItemEdit.ascx control.
How will i overcome this problem.
plz help me this is very urgent.
Thanks n Regards,
Alok....
|
|
|
|
|
If you want to catch the event inside the user control itself, that will not be a problem. For that you can double click on the combobox while in design mode and enviorment will auto generate the handler for the SelectedIndexChanged event by default in side the code behind for .ascx file. But don't forget to set the "AutoPostBack" property of the dropdownbox to true.
If you want to handle SelectedIndexChanted even inside your page where you are using this user control then the quickest souloution is as follows:
Create a public property in your user control like:
public DropDownList List
{
return ddlYourTargetComboBox;
}
on your page do something like:
ucYourUserControlInstance.List.SelectedIndexChanged += new EventHandler(list_SelectedIndexChanged);
void list_SelectedIndexChanged(object sender, EventArgs e)
{
//Implement logic here
}
Hope this helps
|
|
|
|
|
And also add AutoPostBack Property = true along with the above code.
Regards,
Arun Kumar.A
|
|
|
|
|
Hello friends,
I am using rad menu in my project..i want to give a css for that rad menu.
can anybody help me to solve this...if possible give me a small eg or something useful...
regards alex
|
|
|
|
|
Hi all,
I use CssClass for a link(href) but a:active selector dose not worked and I don't know that this error why happned.
|
|
|
|
|
Always try and give some meaningful subject to your question, that will be a lot easier for the people who are here to help you.
Provide some code snippet so that we can help you pointing out the mistake
Mubashir
Software Architect
Storan Technologies Inc, USA
Every job is a self portrait of the person who did it.
|
|
|
|
|
when i was using VS.NET 2005, can't see other classes in one namespase.
In VS.NET 2003 all works.
All classes are public.
|
|
|
|