|
I want to be able to change the culture for a page by pressing an image button with a countries flag, but I'm having problems in that it appears to be ignoring my settings. It works using a dropdown list. Here code sample:-
<%@ Page Language="C#" uiculture="auto" %>
<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="System.Globalization" %>
protected override void InitializeCulture()
{
if (Request.Form["ListBox1"] != null)
{
String selectedLanguage = Request.Form["ListBox1"];
UICulture = selectedLanguage;
Culture = selectedLanguage ;
Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture(selectedLanguage);
Thread.CurrentThread.CurrentUICulture = new
CultureInfo(selectedLanguage);
}
base.InitializeCulture();
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
ListBox1.Text = "en-GB";
InitializeCulture();
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
ListBox1.Text = "es-MX";
InitializeCulture();
}
<asp:listbox id="ListBox1" runat="server" meta:resourcekey="ListBox1Resource1">
<asp:listitem value="en-GB"
="" selected="True" meta:resourcekey="ListItemResource1">English
<asp:listitem value="es-MX" meta:resourcekey="ListItemResource2">Español
<asp:listitem value="de-DE" meta:resourcekey="ListItemResource3">Deutsch
<asp:button id="Button1" runat="server"
="" text="Set Language" meta:resourcekey="Button1">
<asp:imagebutton id="ImageButton1" runat="server" imageurl="~/unionjack.gif" height="50px" onclick="ImageButton1_Click" width="100px">
<asp:imagebutton id="ImageButton2" runat="server" height="50px" imageurl="~/spanish_flag.jpg" width="100px" onclick="ImageButton2_Click">
<asp:label id="Label1" runat="server"
="" meta:resourcekey="Label1">
Clueless
|
|
|
|
|
Hi there,
Are you sure that the execution gets in the body of the if statement? Setting a value to the ListBox.Text property does not make any effect on the Request.Form that basically contains the input values sent from the client side. IMO, you should wrap the sample code in the body of the if statement in a separate private method which takes in the selectedLanguage as the method parameter. Then you can invoke this method both in the overriden InitializeCulture method and in the event handler of the Click event of the ImageButton.
|
|
|
|
|
I can't say I really understand what you mean, but I tried this and this didn't work either
<%@ Page Language="C#" uiculture="auto" %>
<%@ Import Namespace="System.Threading" %>
<%@ Import Namespace="System.Globalization" %>
protected override void InitializeCulture()
{
if (Request.Form["ListBox1"] != null)
InitCult(Request.Form["ListBox1"]);
base.InitializeCulture();
}
private void InitCult(string culture)
{
string selectedLanguage;
selectedLanguage = culture;
UICulture = selectedLanguage;
Culture = selectedLanguage;
Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture(selectedLanguage);
Thread.CurrentThread.CurrentUICulture = new
CultureInfo(selectedLanguage);
}
protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
//ListBox1.Text = "en-GB";
//InitializeCulture();
InitCult("en-GB");
base.InitializeCulture();
}
protected void ImageButton2_Click(object sender, ImageClickEventArgs e)
{
//ListBox1.Text = "es-MX";
//InitializeCulture();
InitCult("es-MX");
base.InitializeCulture();
}
<asp:listbox id="ListBox1" runat="server" meta:resourcekey="ListBox1Resource1">
<asp:listitem value="en-GB"
="" selected="True" meta:resourcekey="ListItemResource1">English
<asp:listitem value="es-MX" meta:resourcekey="ListItemResource2">Español
<asp:listitem value="de-DE" meta:resourcekey="ListItemResource3">Deutsch
<asp:button id="Button1" runat="server"
="" text="Set Language" meta:resourcekey="Button1">
<asp:imagebutton id="ImageButton1" runat="server" imageurl="~/unionjack.gif" height="50px" onclick="ImageButton1_Click" width="100px">
<asp:imagebutton id="ImageButton2" runat="server" height="50px" imageurl="~/spanish_flag.jpg" width="100px" onclick="ImageButton2_Click">
<asp:label id="Label1" runat="server"
="" meta:resourcekey="Label1">
|
|
|
|
|
I didn't notice that you are using the implicit localization with the meta:resourcekey. If you run your application in debug mode you will see that the Text property is already set by the ASP.NET parser by the time the event handler of the Click event of the Image Button executes. The ASP.NET parser gets the values from the resource files based on the culture set in the overriden InitializeCulture. So in this case, you might consider using the Explicit Localization, and get the values from the resource manager to explicitly assign to the property of the control.
|
|
|
|
|
Hi,
My problem seem not to be "Web Development" .
I wrote an application by VBA (inside M$ Access). And I want to connect to another Access file in another computer outside my local network.
So, how could I point out the path of that Access file?
For example: "Provider=Microsoft.Jet.4.0; Data Source = ???"
Should it "Data Source = \\207.46.198.60\Temp\abc.mdb"?
I really don't know
Please help me.
Thanks.
-- modified at 5:29 Wednesday 28th September, 2005
|
|
|
|
|
wat probs u r facing if using the DataSource above?
<< >>
|
|
|
|
|
Couldn't connect to that path.
Though we just use "\\203.162.3.148\Temp" as a local address. But I want to connect to a file outside my network.
|
|
|
|
|
hi there,
kokain wrote:
"\\203.162.3.148\Temp" as a local address
Do u mean that this path is on local server? if so, try to share the folder
and let me know the result
That's just a suggestion.
<< >>
|
|
|
|
|
Nope.
I mean that this path is outside my local network. It's an true internet IP address of an computer/network.
OK, let I clarify again. I wrote my code at home, to connect to an M$ Access file which is stored on the computer at my office. My home computer and office computer is connected to internet, but they're at different network.
"\\[computer]\[shared folder]\[path]" just used as in local network, not outside.
Thanks for your reply.
|
|
|
|
|
Looking for people that will be responsible for designing and coding changes to support the building of eLearning training courses. These changes will be made to an existing architecture that the contractor will be trainined on. One contractor must have the following skills: HTML Javascript The other contractor must have the following skills: HTML Javascript XML, XSL, XSD For both contractors, experience with install packages such as WISE and/or Installshield would be a plus. Client currently has needs for 10 individuals, if we submit your resume for consideration you will have a very good chance of getting the interview. Please send your resume ASAP if qualified!
Send resumes to Kyle.Gagliardi@sapphire.com
Sapphire Technologies is an EOE-M/F/V/D and a member of the Vedior Group of Companies, the third largest international staffing firm with over 2,200 offices in more than 33 countries.
|
|
|
|
|
anyone know of a web based css editor?
|
|
|
|
|
hi there,
from the King Google: ^
<< >>
|
|
|
|
|
In Firefox I can not get the text which is in the iframe.
What am I looking for is something like:
var newvalue = document.getElementById('_editFrame').innerHTML;
alert(newvalue);
However this doesn't work. (it returns empty string to "newvalue")
Can someone help???
|
|
|
|
|
That is probably because the iframe tag actually doesn't contain any html code at all.
Get the innerHTML of the body element of the document object for the page displayed in the iframe instead.
---
b { font-weight: normal; }
|
|
|
|
|
Thanks for the answer but, actually I am writing in the Iframe therefore there is no other body element that I can look into.
Actually, I am trying to write an editor. It consists of an iframe with the content editable property. and i have a button which gets the text when clicked.
So I have to access the iframe's content directly.
Moreover, it works fine with the IE when I use div for the text area. I can not make it work with Firefox...
|
|
|
|
|
But an iframe normally doesn't have any content at all, it displays a page. According to the MSDN documentation on iframes, it doesn't even have the contenteditable property. It doesn't have the innerHTML property either.
If you are using the iframe as it was some other tag, you will of course have problems with it.
---
b { font-weight: normal; }
|
|
|
|
|
However an iframe can be used for content editing. And in firefox it is the only way to do it, i suppose...
I finally solved the problem of retrieving the data:
it can be accessed via contentDocument.body.innerHTML
|
|
|
|
|
Isn't that exactly what I first suggested?
---
b { font-weight: normal; }
|
|
|
|
|
Yes it is, I restated it for the records
thanks in advance...
|
|
|
|
|
Hi all,
How can I trigger the "enter" key press event programmatically in javascript?
Thanks
Tony
|
|
|
|
|
I want to develop a page which will search the pages of my web site throgh meta tag. i cannot understand how i get data from meta tag into my apllication that is asp/vbscript.
please help me
|
|
|
|
|
Use FileSystemObject to iterate and open the files. Use a regular expression to easily extract the contents of the meta tag from the source.
(I assume that the meta tags are not dynamically created, in that case you would have to use the xmlhttp component the request the pages from the server.)
---
b { font-weight: normal; }
|
|
|
|
|
Hey all, Probably a easy question, but doing my head in. Is there a function that serves the same purpose javascript document.write but in c# so i can use it in the code behind class? or is there a way to use the document.write in the codebeinf class.
|
|
|
|
|
Is document.write the same as response.write ?
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
Thanks for the quick response Christian,
response.write will work, but the problem is that it writes it to the aspx page where i need to write the html to the a usercontrol which sit within a aspx page. Any idea how i can achieve this? basically i want to add html dynamicaly to the user control and not the aspx page.
Thanks inadvance
|
|
|
|