|
I have an aspx page. In that page I am displaying div when click on link. Div contains iframe and i am assigning url to the frame like below.
<asp:linkbutton id="lkbtn" text="Create" onclientclick="return ShowDiv(this)" runat="server">
<asp:label text="Create" runat="server" forecolor="Chocolate" font-bold="true">
| X
|
|
// Function to Show the Div //
function ShowDiv(CtrlName)
{
document.getElementById('divUserCtrl').style.display = 'inline';
frames['ifrm'].window.location = "CreateProject.aspx?ProjCat=G";
return false;
}
when click on linkbutton can able to display div and redircting to CreateProject page. But in CreateProject when click on a button i need to close this div. How can I do this in c#. I tried like Page.RegisterStartupScript("Reload", "window.close();"); But no luck
|
|
|
|
|
You may get an answer here but you will be more likely to succeed here[^]. If you decide to post there, link to your question above so you don't get flamed for cross posting!
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
dear all
how to scale or zoomx and zoomy for one image size? for example, my image size is 1624, 1224, but my pictureBox is 680,580, how to scale and zoomx and zoomy, make sure all image will be centered and display in the pictureBox. thanks
|
|
|
|
|
Try google search[^].
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
Hi,
You should look at the SizeMode property of the PictureBox class.
This is really a simple issue, you should look for properties of objects you're using before posting on this forum. If you give yourself a little effort, people here will be more likely to help you.
Regards.
|
|
|
|
|
Could someone tell me please, what is the difference between the following two blocks of code? When would you assign an initial value for a field in the field definition and when would you do it in a constructor?
public class MyClass
{
private int myField;
public MyClass()
{
myField = 123;
}
}
public class MyClass
{
private int myField = 123;
public MyClass()
{
}
}
Thanks in advance
|
|
|
|
|
Hi Dewald,
It's more a matter of design choice, since there's no real functional difference between both your propositions.
Personnaly I'd rather use the first one. I only assign values to constants at declaration. I find this way much clearer (maybe because I always do this way). Moreover, it allows consistence of design if you want to set up the following :
public class MyClass
{
private int myField;
public MyClass() : this(123) {}
public MyClass(int field)
{
myField = field;
}
}
Perhaps you can try both ways, compile, and see what is the difference in the generated IL Code (with the IL disassembler). I never did such a test myself.
Hope this helps. Regards.
|
|
|
|
|
First option, as it allows me to put a breakpoint on the assignment
I are Troll
|
|
|
|
|
I always use the first method for the resons given already and also I may have several constuctors which may require a different initial value to be set e.g.
public class MyClass
{
public const int DefaultMyField = 123;
private int myField;
public MyClass()
: this(DefaultMyField)
{ }
public MyClass(int myField)
{
this.myField = myField;
}
}
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
I tend toward the first as well, for consistency.
public class X
{
int y ;
int z ;
public X
(
int y
)
{
this.y = y ;
this.z = 42 ;
return ;
}
}
z could be initialized where it's declared, but y can't, so I initialize z in the same place y is initialized.
|
|
|
|
|
The following part of the C# language spec may be of some interest:
§17.4.5 Variable initializers (skipped the example)
The default value initialization described in §17.4.3 occurs for all fields, including fields that have variable
initializers. Thus, when a class is initialized, all static fields in that class are first initialized to their default
values, and then the static field initializers are executed in textual order. Likewise, when an instance of a
class is created, all instance fields in that instance are first initialized to their default values, and then the
instance field initializers are executed in textual order. When there are field declarations in multiple partial
type declarations for the same type, the order of the parts is unspecified. However, within each part the field
initializers are executed in order.
All of this happens before any code in the ctor is run, as detailed in:
§17.4.5.2 Instance field initialization
The instance field variable initializers of a class correspond to a sequence of assignments that are executed
immediately upon entry to any one of the instance constructors (§17.10.2) of that class. The variable
initializers are executed in the textual order in which they appear in the class declaration. The class instance
creation and initialization process is described further in §17.10.
|
|
|
|
|
dear all
i am a newbe, this is a basic issue. i want to get a form's width height, and other property in another form. so how i can achive this point? thanks.
|
|
|
|
|
Hi,
Your question is not clear. Could you tell us what you've done so far to get what you want, and which issues you encountered ?
|
|
|
|
|
One of the ways is:
From Form1 get Height and Width of Form2 by:
Form2 frm2 = new Form2();
int height = frm2.Height;
int width = frm2.Width;
I Love T-SQL
"Don't torture yourself,let the life to do it for you."
If my post helps you kindly save my time by voting my post.
www.aktualiteti.com
|
|
|
|
|
Assuming you have a reference to the other form then you can access its properties.
It's time for a new signature.
|
|
|
|
|
thanks first.
if i have such dialogs
InspectionImageDialog m_ImgDlg = new InspectionImageDialog();
InspectionResultDialog m_RltDlg = new InspectionResultDialog();
Intel_Amd_InfoDialog intelamdDialog = new Intel_Amd_InfoDialog();
i would like to only new once and i can use this instance in anywhere of my project. how to do that? so far, i have 3 forms above and 1 mainDlg, so i want to control 3 dialogs in my mainDlg, also sometimes i want to get some property in other dialog. so how to new a instance and then i can use this instance freely and get its property and asign value or get value there.
|
|
|
|
|
|
Keep the references to your dialogs or forms in your main form class or make them global so that you can refer to them in any module.
It's time for a new signature.
|
|
|
|
|
how to keep the reference for dialog or forms in my main form class? could u give me an example?thanks
|
|
|
|
|
I don't quite understand your problem with this. Just add a variable of the correct form type to your main form, create the new form and save the reference. You could do this in your constructor or create a special method that does it on demand; either way your other forms will remain until you destroy them. Then you can use that from anywhere in your main form code.
It's time for a new signature.
|
|
|
|
|
If you want to access an object instance from anywhere, the Singleton pattern[^] is the recommended method. Are you sure you want to do this for three forms though? Static/Singletons have their place and uses but can often be the result of poor design, poor undestanding of OOP, lazyness. I'm not saying "don't", just be sure that it is actually required!
DaveIf this helped, please vote & accept answer!
Binging is like googling, it just feels dirtier.
Please take your VB.NET out of our nice case sensitive forum.(Pete O'Hanlon)
BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
|
|
|
|
|
Using White in .net
how shall i get the DatagridView object in White
thanks in advance
|
|
|
|
|
Your question is not very clear.
What is 'White'?
Do you mean the color White, or are you referring to a third party library called White?
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
In .net we've got several timers, but all of them specify an interval to elapse rather than a specific time to come. I'd like to implement a timer which specifies a specific time, say to be triggered at the time of 10:25:15am (hour:minute:second). Using polling tech to determine if it's the right time to trigger is a very bad way and inefficient, I'd like to put the timer to sleep, then when the time is coming it receives a signal from the system to be woken up and then do its work.
One way to do this is still based on the Threading.Timer, convert how long to wait for the specific time into interval. But is there any mechanism provided by .net directly supporting this scenario to signal the thread at specific time?
Many thanks.
|
|
|
|
|
I'm not aware of any explicit support for a due time.
For a 1-second resolution I would just pick some timer (Windows.Forms/Threading/Timers depending on circumstances) and use DateTime and TimeSpan classes to calculate and set the delay.
For a finer resolution, I'd start with the above, then probably execute some polling loop within the final second, including a Thread.Sleep(ms) with a number of milliseconds fitting the resolution (assuming >= 50)
Whatever you do, keep in mind things could go wrong in several ways:
- your PC might get very busy while calculating and setting the due time, resulting in a late call;
- your PC might get very busy at the due time, so the requested action may actually run somewhat later;
- your PC might be switched off or crash in the mean time.
Depending on your requirements a Windows scheduled task may or may not be a better option.
|
|
|
|