|
I got a master page with some contentTemplateHolders in one of them I load the main screens (user controls) depending on the menu selected, localization works fine for theses ones, you can see the correct language depending on the user who logged in.
But then for my master page it doesn't work, and I followed the same steps than for the other user controls, just creating resource file, and adding the culture code to name of that file, for others contentTemplateHolders which are in the master page localizatin doesn't work either.
The only difference between those templateHolders is that in one of them i load the page dinamically, but the others are always in the master page, all of them are user controls. As well for the controls which are added directly to the master localization doen't work.
I change the culture in mainForm in the method Page_Init, this comes from a class user, where we hold all the data realted to the user like culture, and actually hits the method and changes correctly the culture..
Can anyone tell me how to do the localization with a master page? Any idea why it works with some user controls (the one loaded automatically) and not for others?
Any help will be more than appreciated.
Thanks a lot!
Jaime.
|
|
|
|
|
|
Thanks for your answer Urs!
I'm gonna try to implement something similar, but there is still something missing, that will work for the user controls which are held in the placeholders but what about the controls I got actually inside the masterpage (not in placeholders)? because master page won't inherit that basepage, and they don get the localization either.
Any suggestions?
cheers!!!
|
|
|
|
|
If your page inherits from the base page handling the current culture, your master page will, too.
Masterpage and page are not two seperated objects, they are "merged" to one single object, therefore if your page inherits the behaviour then your master page, too.
-^-^-^-^-^-^-^-^-^-^-^-
no code is free of bugs
|
|
|
|
|
Thanks for your help Urs!
But at the end I found another solution which I think is easier than the one that everybody seems to use. Simply I set the Thread.CurrentThread.CurrentCulture and Thread.CurrentThread.CurrentUICulture in the global.asax inside the method Application_BeginRequest, and that's it, the master page now changes, and I don't need to create any base class or anything.
|
|
|
|
|
Yes you are right, this works, too.
I use the base class approach because I have a base class anyway (it's doing a lot of security stuff, too).
Happy coding!
-^-^-^-^-^-^-^-^-^-^-^-
no code is free of bugs
|
|
|
|
|
I was wrong! the file is Global.asax but the method is not Application_BeginRequest, is Application_PreRequestHandlerExecute, got problems using Application_BeginRequest with the session object, so far is working properly in Application_PreRequestHandlerExecute.
|
|
|
|
|
My .net application needs to use the drag and drop functionality, and draw the shapes on to a dialog box. So is it possible to use Microsoft Word features something like drag and drop a shape (circle, square box etc). So is there any way to add MS-Word features to .net applications;
|
|
|
|
|
|
Below code I have downDownlist in EditItemTemplate of gridview. I want to assign data source to downDownlist while editing the row. RowDataBound is called twice once before DropDownList is loaded and once after that.
Q1: So I need to check condition “Not e.Row.FindControl("DropDownList1") Is Nothing“. Is there any other way to know whether “DropDownList1“is loaded.
Q2: Why RowDataBound is called before DropDownList is loaded
<asp:TemplateField HeaderText="Dept">
<ItemTemplate>
<asp:Label runat="server" ID="Label1" Text='<%#GetDept(Container.DataItem) %>' ></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:DropDownList ID="DropDownList1" runat="server">
</asp:DropDownList>
</EditItemTemplate>
</asp:TemplateField>
Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound
If GridView1.EditIndex >= 0 And Not e.Row.FindControl("DropDownList1") Is Nothing Then
CType(e.Row.FindControl("DropDownList1"), DropDownList).DataTextField = "DeptName"
CType(e.Row.FindControl("DropDownList1"), DropDownList).DataValueField = "DeptID"
CType(e.Row.FindControl("DropDownList1"), DropDownList).DataSource = ds.Tables(1)
CType(e.Row.FindControl("DropDownList1"), DropDownList).DataBind()
CType(e.Row.FindControl("DropDownList1"), DropDownList).SelectedValue = GridView1.DataKeys(e.Row.RowIndex)(1)
End If
End Sub
Protected Sub GridView1_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles GridView1.RowEditing
GridView1.EditIndex = e.NewEditIndex
BindGridView()
End Sub
Thanks in advance,
Regards,
Geeta Pavate
|
|
|
|
|
Here is a question regarding best coding practices involving exceptions
Scenario:
You are the developer of .NET components to be used by other developers in creating enterprise applications. You have been tasked to build a widget value calculator.
As is well-known in the widget industry, widget value is a function of weight. You are ready to engage your development skills in developing a spectacular widget value calculator, however, knowing nothing about how or where your function will be used, not to mention the capabilities of the developers who will use it, you are vexed by one simple question: how to handle the situation where a user of your function sends a meaningless input to the function, which, in the case of widgets, would be a negative weight.
You recognize that there are basically two options:
A) throw an exception whenever a negative weight is supplied to your function, or,
B) do not throw an exception, but use a return object or property to indicate that an invalid argument was supplied, and set the actual return value to zero.
You know that, if you choose option A, your component may crash the application if the developer of that application did not anticipate and handle potential exceptions. You are also aware that, if you use a return object or property to indicate a problem WITHOUT throwing an exception, the developer using your function might forget to check that value and continue processing with bad or missing data.
You understand the implications of exception usage and handling, you believe in good coding practices, and you want to build a superior product. Which option do you choose?
This has been the topic of a week-long, heated debate in our group. We all have very strong opinions for option A or B. Seriously, any input is appreciated. Please do not hold back in expressing your opinion on this!
Don Boinske
|
|
|
|
|
Follow the Design by Contract Model for exception.
http://www.codeproject.com/csharp/designbycontract.asp
|
|
|
|
|
I strongly prefer A.
Better fail the application that return wrong data (okay this may lead to rocket explosions though - Arian ?)
If you throw an exception then you will detect that something went wrong, whereas the not checked return value may be missed.
Furthermore, in my opinion the use of exception handling for this kind of "logic" leads to easier code (in understanding and maintaining).
And a side note to the post above (using contracts like in Eiffel): you will get the error in development but not in production because you normally turn off input validation to gain performance (at least this was what Bertrand Meyer tells in his lectures).
Therefore A and A again
-^-^-^-^-^-^-^-^-^-^-^-
no code is free of bugs
|
|
|
|
|
boinske wrote: A) throw an exception whenever a negative weight is supplied to your function
Might I suggest an ArgumentOutOfRangeException[^] for this.
boinske wrote: B) do not throw an exception, but use a return object or property to indicate that an invalid argument was supplied, and set the actual return value to zero.
No. The caller should be aware of the range of permitted arguments therefore any argument that is not valid should be rejected with an exception. It is an exceptional circumstance that the method receives an out of range argument.
boinske wrote: You know that, if you choose option A, your component may crash the application if the developer of that application did not anticipate and handle potential exceptions.
Not your problem. If the developer using the component isn't keeping within the defined parameters then that is their fault. The .NET Framework throws exceptions all the time. What do you do with them? You either fix the problem that caused the exception or handle them in a catch block somewhere.
Just make sure that the limits are clearly documented and the exception message explains what went wrong.
boinske wrote: This has been the topic of a week-long, heated debate in our group. We all have very strong opinions for option A or B. Seriously, any input is appreciated. Please do not hold back in expressing your opinion on this!
It shouldn't be the subject of a heated debate. The answer is a no brainer. Use exceptions. There is even an exception in the framework for this.
I should stress that regardless of what option you choose you WILL be blamed for bugs and errors that are not yours. With exceptions you at least have the opportunity to deflect some of that by indicating in the exception message what caused the problem.
|
|
|
|
|
Colin makes excellent points, and I want to add to them.
If you rely on return statuses, then you have introduced a weakness into the system whereby further processing can be performed on values from your widget because the system consuming your widget has chosen to ignore statuses. Return values tended to be used by systems that existed before SEH (structured exception handling).
One argument that you will sometimes hear is that you can do the same as above by wrapping the code in a try/catch block and then ignore the fact that you received an error and continue processing with incorrect values. This is true, but misses the point that the developer has chosen to ignore the exception. They are aware it exists, but they are doing nothing with it - this is a deliberate choice and not an omission.
The simple fact is - an exception exists to show that something Exceptional has occurred (i.e. something outside the norm). If your inputs don't conform to expected values, then this is Exceptional processing.
One thing that hasn't been mentioned is testing. It's reasonable to assume that people who are using your component perform their own testing. As long as you've documented the conditions that can lead to the exceptions, then you give the consumers of the component a chance to develop their own tests. It can help to give them a hint as to areas where their code might go wrong.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
I would delegate the decision to the application developer (he/her is your customer). You can add a boolean property ("throw" or "return"), and set the default to "throw".
Regards
|
|
|
|
|
A is best, every time.
But if your function uses integers (rather than floating point values) use unsigned types and avoid that whole problem altogether.
|
|
|
|
|
Hi,
I'm having real problems getting my MSBuild script to work. I've got various projects that all need to be built (in the correct order as there are various project references)
I'm trying to write a build script to build all the projects, and output the binaries to a single location.
I'm trying to use the MSBuild task to build all the project files. But if I just specify all the project files, the dependancies don't exist and it won't build. So I split it up into a seperate target for each project. I had hoped each target would build the required project, copy the binaries to the common directory, and then the next project could reference the already built binary (using the referencepath property of the msbuild task). Problem is that the Copy task doesn't seem to copy the files, It's as if the MSBuild task doesn't actually write out the binaries until after the copy task has run, because if I run the build again, the copy works fine, it just never works the first time when there are no binaries to start with.
This is what i've got so far:
<Project DefaultTargets="BuildAll" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<ProjectLibrary Include="C:\Source\Library\Library.csproj"></ProjectLibrary>
<ProjectFramework Include="C:\Source\Framework\Framework.csproj"></ProjectFramework>
</ItemGroup>
<PropertyGroup>
<Configuration>Release</Configuration>
<DestFolder>Deployment\</DestFolder>
</PropertyGroup>
<ItemGroup>
<ProjectLibraryOutputFiles Include="C:\Source\Library\bin\$(Configuration)\*.*"></ProjectLibraryOutputFiles>
<ProjectFrameworkOutputFiles Include="C:\Source\Framework\bin\$(Configuration)\*.*"></ProjectFrameworkOutputFiles>
</ItemGroup>
<Target Name="LibraryBuild">
<MSBuild Projects="@(ProjectLibrary)" ContinueOnError ="false" Properties="Configuration=$(Configuration);ReferencePath=C:\Build\Deployment">
</MSBuild>
<Copy SourceFiles="@(ProjectLibraryOutputFiles)" DestinationFolder="$(DestFolder)"></Copy>
</Target>
<Target Name="FrameworkBuild" DependsOnTargets="LibraryBuild">
<MSBuild Projects="@(ProjectFramework)" ContinueOnError ="false" Properties="Configuration=$(Configuration);ReferencePath=C:\Build\Deployment">
</MSBuild>
<Copy SourceFiles="@(ProjectFrameworkOutputFiles)" DestinationFolder="$(DestFolder)"></Copy>
</Target>
<PropertyGroup>
<BuildAllDependsOn>FrameworkBuild</BuildAllDependsOn>
</PropertyGroup>
<Target Name="BuildAll" DependsOnTargets="$(BuildAllDependsOn)"/>
</Project>
I've also tries putting the copy task in a seperate target, but that doesn't work. I've tried using this "<Output ItemName="OutputFiles" TaskParameter="TargetOutputs"/>" in the MSBuild task, but that only produces a list of the binaries, which is no good as I also want the .pdb/.config and various other supporting files to be copied.
I've looked all over for how to achive this, but I can't find anything. Can anybody point me to a good resource, or templates for building multiple projects with a MSBuild Script (I was using the example from this page, but it doesn't deal with references between the projects or copying the non binary files http://www.sedodream.com/PermaLink,guid,ed3a0c98-fdac-4467-9116-5b3bf6755abc.aspx)
Thanks
Simon
|
|
|
|
|
MSBuild might not be your easiest option for this. Have you looked at NAnt instead? I think it's a lot easier to work with than MSBuild.
|
|
|
|
|
Thanks.
I Did consider that for a while, but i'm going to stay with MSBuild for now as i've solved the problem.
(For anyone else with similer issues. The problem was that the output files item groups are populated first. So when the build occurs, the files then exist, but they aren't in the item groups. To fix the issue, you need to make a list that isn't populated until after the build has occured. So create a target for coping the files, and include a createItem task in it to create a list of the files. This will now contain the full list of files provided the task is run after the build occurs.
<CreateItem Include="C:\HGT Source\dotNetDevelopment\Library\Hadley.Library\bin\$(Configuration)\*.*">
<Output ItemName="ProjectLibraryOutputFiles" TaskParameter="Include"></Output>
</CreateItem>
Easy
Simon
|
|
|
|
|
If anyone could point me in the right direction, I would be very grateful.
I have a main form, which shows other smaller forms. These forms must always be on top of the main form, but not on top of other forms. Similar to the tool windows in photoshop. Obviously a TopMost form is not the right choice here.
I am not wanting to use MDI child windows.
Any ideas?
www.wickedorange.com
www.andrewvos.com
|
|
|
|
|
AFAIK that is exactly what Form.Owner does
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
Whoa.
Thanks alot! Can't believe I didn't know that was there!
I guess I get to delete all those api declares now
www.wickedorange.com
www.andrewvos.com
|
|
|
|
|
Hi
I am having some issues with installation / deployment of a vb.net project, which are because of some OCM & Activex components
- I had originally made most of the application in vb6
- Then we converted the codes to vb.2005 express
- Then some more development was done
- Now the issue is that when we try to install the application on a client’s machine (which dose not have VB6 installed), the application dose not work
- After investing some time we found out that the issue is due to non availability of vb6 COM & Activex components
How do we add the reference of these COM component to the setup and export the DLL’s with it
Regards
Nishkarsh
-- modified at 6:10 Tuesday 13th November, 2007
|
|
|
|
|
Please don't put the phrase "need urgent help" in your message. It is rather rude.
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|