|
Try LoadControl("/yourusercontrol.ascx")
|
|
|
|
|
Dynamicaly adding control's with out refreshing the page
|
|
|
|
|
You can only add the javascript or html control without refreshing the page.. If you want to add the server control, I think it will be too difficult.. You may want to check the ASP.NET Ajax...
|
|
|
|
|
use Java script to add the control dynamically, without refreshing the page.
example:
<br />
<div id="panel"></div><br />
<script language="javascript"><br />
var btn=document.createElement("input");<br />
btn.type="button";<br />
btn.value="Click me";<br />
btn.onclick=function()<br />
{<br />
alert("Btn Clicked");<br />
}<br />
panel.appendChild(btn);<br />
</script><br />
Manikandan.net
[Coding is life]
|
|
|
|
|
hi guys ,,
i am having some security issues on dot net 2.0,
i am running exe of my project from a shared location on my lan but i get some
security rellated errors ,"unveriafiable code.", but when in frame configuration i make
trusted level full of the intranet zone i get no error and it works fine, but it gives me more
probelms, do i have to make these setting on individual pc(too hard)?
simply is there any way that i could make my assemblies to run in partial trusted zones?
thansk in advance
|
|
|
|
|
ghumman63 wrote: do i have to make these setting on individual pc(too hard)?
Yes.
ghumman63 wrote: simply is there any way that i could make my assemblies to run in partial trusted zones?
Nope. You'd still have to go to each machine and tell it to trust that assembly.
If the machines are in a domain environment, then it's easy to do with a group policy.
Read this[^], then this[^], and then this[^].
Basically, you have to tell the machines to trust any assembly signed with a certain key.
|
|
|
|
|
thanks for your cincideration,
but any guide about doing that (group policy) any hepling stuff or web link,,
thanks in advance
hello
|
|
|
|
|
|
Can I use a delegate to write to a textbox on a 2nd form from a running subthread on the first form?
For instance, this code works fine to write from the thread to Me.Textbox1. However, if I change Me.Textbox1 to Form2.Textbox1 then the delegate does not write to that textbox on Form2 (no error, just blank textbox).
Thanks!
Public Sub ThreadProcSafe()
Me.SetText("This text was set safely.")
End Sub
Private Sub SetText(ByVal [text] As String)
If Me.TextBox1.InvokeRequired Then
Dim d As New SetTextCallback(AddressOf SetText)
Me.Invoke(d, New Object() {[text]})
Else
Me.TextBox1.Text = [text]
End If
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Me.demoThread = New Thread(New ThreadStart(AddressOf Me.ThreadProcSafe))
Me.demoThread.Start()
'Form2.Show()
End Sub
|
|
|
|
|
I think you can. But I've always heard that crossing over threads is not the best, though.
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
yes but before you can access the textbox properties, you must do an invoke to get the population of the textbox onto the main thread...
'Never argue with an idiot; they'll drag you down to their level and beat you with experience.' ~ anonymous
|
|
|
|
|
I'd like to be able to load an assembly and then unload it, thereby allowing the user to edit and recompile the assembly (via Codeprovider). Then I want to reload the new recompiled assembly.
But the unload statement below doesn't free the .dll so that I can write to it again.
Is there a way to do this?
thank you!
Dim SubDomain As AppDomain
Dim as1 As Assembly = Reflection.Assembly.ReflectionOnlyLoadFrom(TypeToOpen & ".dll")
StrategyClass = SubDomain.CreateInstanceAndUnwrap(as1.FullName, "Strategies.Strategy")
AppDomain.Unload(SubDomain)
|
|
|
|
|
Hi,
AFAIK AppDomain.Unload is the only way to get rid of a loaded DLL.
|
|
|
|
|
Hello every one
I am new in vb.net and i am doing one simple application to save text file, and i have provide choice to display image in picture box but i am not saving image in file file can only save students name,age,class etc but i am haveing problem to save file,but if i dont load image in picture box then it's works fine again i am not saving image in file it's just for selecting image from file
can some one please help me with this
code is some thing like this (for creating profile)
Private Sub btnProfile_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnProfile.Click<br />
Dim Response As DialogResult<br />
Dim Age As String<br />
Dim MyString, MidString, MidString2 As String<br />
'get first leter in upper case for text box for name <br />
txtName.Text = StrConv(txtName.Text, VbStrConv.ProperCase)<br />
If Trim(txtName.Text) = "" Then<br />
Response = MessageBox.Show("Please enter your name", "Error", MessageBoxButtons.OK, _<br />
MessageBoxIcon.Error)<br />
If Response = DialogResult.OK Then<br />
txtName.Focus()<br />
Exit Sub<br />
End If<br />
End If<br />
Age = Str(DateDiff("yyyy", DOB, Now))<br />
Message = "Your profile was created on " + ((Format(DateTime, "d MMMM yyyy") + _<br />
" at " + Format(DateTime, "hh : mm tt" + ControlChars.Cr)))<br />
Message += "" + ControlChars.Cr<br />
Message += txtName.Text + " is a student in the " + cboGrade.Text + " grade " + ControlChars.Cr<br />
If rdoMale.Checked Then<br />
Message += "He is " + Age + " years old" + ControlChars.Cr<br />
ElseIf rdoFemale.Checked Then<br />
Message += "She is " + Age + " years old" + ControlChars.Cr<br />
End If<br />
If picStudent.Image Is Nothing Then<br />
Message += "" + ControlChars.Cr<br />
Message += "No picture added " + ControlChars.Cr<br />
Else<br />
Message += "" + ControlChars.Cr<br />
Message += "Your picture was also added in your profile" + ControlChars.Cr<br />
End If<br />
Response = MessageBox.Show(Message, "Student Profile", MessageBoxButtons.OKCancel, _<br />
MessageBoxIcon.Information)<br />
'Add data in to student data file<br />
Call AddStudentData()<br />
'Add student name in to cobmobox<br />
Call AddDataToCombo()<br />
If Response = DialogResult.OK Then<br />
Response = MessageBox.Show("Would you like to creat another profile", "New profile", _<br />
MessageBoxButtons.YesNo, MessageBoxIcon.Question)<br />
'if cancel then reset form<br />
ElseIf Response = DialogResult.Cancel Then<br />
txtName.Text = ""<br />
cboGrade.SelectedIndex = 0<br />
txtName.Focus()<br />
nudDay.Value = 1<br />
dudMonth.SelectedIndex = 0<br />
nudYear.Value = 1951<br />
picStudent.Image = Nothing<br />
Exit Sub<br />
End If<br />
'if new profile and yes then reset form<br />
If Response = DialogResult.Yes Then<br />
txtName.Text = ""<br />
cboGrade.SelectedIndex = 0<br />
txtName.Focus()<br />
nudDay.Value = 1<br />
dudMonth.SelectedIndex = 0<br />
nudYear.Value = 1951<br />
picStudent.Image = Nothing<br />
Exit Sub<br />
End If<br />
If Response = DialogResult.OK Then<br />
txtName.Text = ""<br />
cboGrade.SelectedIndex = 0<br />
txtName.Focus()<br />
picStudent.Image = Nothing<br />
Else : Me.Close()<br />
End If<br />
End Sub
and code for loading image in picture is
Private Sub btnPicture_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPicture.Click<br />
'load picture of student<br />
If dlgOpen.ShowDialog = DialogResult.OK Then<br />
picStudent.Image = Image.FromFile(dlgOpen.FileName)<br />
End If<br />
End Sub
and code for saving students profile,display profile and add students name in combo box is like this
Private Sub AddStudentData()<br />
Dim DataWriter As StreamWriter<br />
FileName = Trim(txtName.Text) + ".txt"<br />
DataWriter = File.CreateText("StudentData\" + FileName)<br />
DataWriter.WriteLine(Message)<br />
DataWriter.Close()<br />
cboData.Items.Add(FileName)<br />
<br />
End Sub<br />
Private Sub AddDataToCombo()<br />
cboData.Items.Clear()<br />
Dim files() As String = Directory.GetFiles(Application.StartupPath + "\StudentData")<br />
For i As Integer = 0 To files.Length - 1<br />
cboData.Items.Add(Path.GetFileNameWithoutExtension(files(i)))<br />
Next<br />
If files.Length = 0 Then<br />
cboData.Text = "Empty Student Database"<br />
Else<br />
cboData.Text = "Select name to display profile"<br />
End If<br />
End Sub<br />
Private Sub DisplayData()<br />
Dim DataReader As StreamReader<br />
DataReader = File.OpenText("StudentData\" + cboData.SelectedItem.ToString + ".txt")<br />
FileName = DataReader.ReadToEnd<br />
MessageBox.Show(FileName, "Student Database", MessageBoxButtons.OK, MessageBoxIcon.Information)<br />
DataReader.Close()<br />
End Sub
any help please
have a nice X-mas and new year to all
thanks
|
|
|
|
|
Instead of posting the entire code, just post the trouble spot. What is the problem you are having?
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
The Image.FromFile method locks the file the image was created from for the lifetime of the Image object you created.
Look into using Image.FromStream instead.
|
|
|
|
|
I think I spot a problem with your reply... :P
Dave Kreskowiak wrote: The Image.FromStream method locks the file
Dave Kreskowiak wrote: Look into using Image.FromStream instead.
:P
Christian Graus - Microsoft MVP - C++
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Whoops! Hey, someone reads my reply's!! They really, really do!
|
|
|
|
|
Hello sir
sorry for late
but sir i dont know how to correct this error, again i dont want to save image in file it's just for display so i dont select image then it's works fine but if i select image then it's a problem so sir can you please tell me more how to solve this problem as you said look in to using Image.FromStream
so i am confuse
waiting for your kind rep.
wish you very happy new year
thanks
|
|
|
|
|
Let me repeat myself. When you try to write over a file that's already open, you'll get this error. When you use Image.FromFile to load an image, Image will lock that file open for the lifetime of the Image object. Use Image.FromStream to get the data from the file and the file won't be locked.
|
|
|
|
|
hello sir
thanks for your kind rep.
you mean do i need to do some thing like this
picStudent.Image = Image.FromStream(dlgOpen.FileName)
to open the image or some thing else
like i said before i am not saveing image in file it's just for display image in picture box that's what my assignment says, what i need to save only customer's details only,if i save only details then it's works fine,
but sir still i am confuse
waiting for your kind rep.
thanks
|
|
|
|
|
Have you ever used the FileStream class to open files??
|
|
|
|
|
hello sir
as i said i am new in vb.net and i am learning so i dont know much about this, and as you said try to use Image.FileStream and when i open file from file dialog box it looks files which is all ready open so i am confuse there that which file is open, like in this project when i click btnProfile it's create file to store and with out image it's works fine, but if i load image from dlgOpen then it's problem, but dlgOpen is different and write file from StreamWriter is different that's what i understand but i am not sure that i am right or wrong so please sir can you tell me some thing more about this, and i am sure that you have found that problem but i am not getting there that's the only problem
waiting for your kind rep.
have a nice day
thanks
|
|
|
|
|
bapu2889 wrote: and when i open file from file dialog box it looks files which is all ready open
What?? This doesn't make any sense. I think you have a mistaken idea about how the OpenFile dialog works. All it does is return a string representing the path to a file. It doesn't acutally open the file, unless you speicifically tell it to AFTER the dialog returns to your code.
All you do to open a file using FileStream is:
Dim fs As New FileStream(filePath)
Dim pic As Bitmap = Image.FromStream(fs)
fs.Close()
fs.Dispose()
Image file is locked when you set the PictureBox Image property to a file[^]
|
|
|
|
|
hello sir
first of all thanks for quick rep.
now i will try to fix this problem
thanks again
have a nice day
wish you very happy new year
|
|
|
|