|
Don,
I am not clear with your question. My apl for this. Could you please explain it? May be i'll be able to help you.
|
|
|
|
|
The way to do this is to insert it into a script, something like
string script = "var myVar = '" + myControl.ClientID + "';";
RegisterClientScriptBlock(script);
or in your aspx
var myVar = '<%#myControl.ClientID%>';"
In the first case, you need to add a script block to the string, top and bottom, and in the second, you need to put it in a script block. You can pass any value you can turn into a string, I'm just illustrating using a control's client side id, as that's the value I find is mostly often needed, for UI or AJAX stuff on the client side.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Hi Christian Graus
If you have a minute, Could you please provide some good example?
Thanks
Amit
|
|
|
|
|
I'm not sure how you mean, what better example do you need ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Does the LoadComplete event get skipped for User Controls? I've hit this issue and worked around it for the most part but now it's just plain getting annoying. Is there an equivalent event for user controls?
Thanks,
Keith
|
|
|
|
|
Hi
I am trying to create a datagrid with controls bound to each records column, I have made the following declaration for the button
<asp:GridView ID="dataGrid1" runat="server" DataKeyNames="id" >
<Columns>
<asp:ButtonField Text="Delete" buttonType="Button" commandName="Delete" />
</Colummns>
</asp:GridView>
I have also created the necessary subroutine, which should be executed when button is clicked, but i can't get the buttons to run the sub, when i click on them, the sub has the following declaration below
Any Suggestions forum
Thanks in advance
boy
Sub DataGrid1_DeleteCommand(ByVal s As Object, _
ByVal e As DataGridCommandEventArgs)
Dim connectionString As String
connectionString = "Server=lo; uid=; pwd=;database=test;"
Dim conn As MySqlConnection
Dim cmd As MySqlCommand
Dim Id As Integer
Id = CInt(e.Item.Cells(0).Text)
If Id <> Session("CustomerIdToDelete") Then
lbl1.Text = _
"Press the Delete button again if you want to " & _
"delete customer id #" & Id.ToString
Session("CustomerIdToDelete") = Id
Return
End If
Session("CustomerIdToDelete") = -1
conn = New MySqlConnection(connectionString)
cmd = New MySqlCommand("sp_myDelete", conn)
cmd.CommandType = CommandType.StoredProcedure
cmd.Parameters.Add("?sp_Id", SqlDbType.Int).Value = Id
cmd.Connection.Open()
cmd.ExecuteNonQuery()
cmd.Connection.Close()
displayResults()
End Sub
|
|
|
|
|
You are missing runat="server" in the buttonfield
Hope that helps.
Ben
|
|
|
|
|
Thats not a valid operation in a buttonfield apparently, guessing because its nested in the datagrid
|
|
|
|
|
Ah, It looks like your method you created doesn't have any handels on it. so it is not linked to any event. Most likely you need to add something like handels gridview.RowCommand
you would also want to add some code in your method that does something like:
if e.commandName = "Delete" Then
So that your code only runs when a delete command is passed to the method.
Hope that helps.
Ben
|
|
|
|
|
still not much joy it doesn't like the handles statement, can't track down my command thru the windows, jus says signature not recognised
|
|
|
|
|
Go to your aspx.cs file where your datagrid is located. Then in the left drop down find the datagrid control. Then in the right dropdown you should be able to select the datagrid command event. When you select it, it should create the method for you. Take your code from the method you created and put it in the auto generated method.
Hope that helps.
Ben
|
|
|
|
|
Hi ,
I m using a webservice to copy a file to a remote server. When i do that i m getting ' Access to path denied' error. Pls let me know what permission i need to give. My OS is windows 2000.
I tried giving impersonate = true in web.config.
Thanks in advance
Priya
|
|
|
|
|
Your webservice is running under an application pool. The user that the app pool is running as needs rights to write to that remote server. I would suggest creating a new app pool that only the web service will run under. Then you could create a specific network user that has just the correct rights to write to your remote server.
Hope that helps.
Ben
|
|
|
|
|
Hi
how can i call server side function on onblur event of textbox.
i write this tag but it gives error.where i am
going wrong. onblur=<%# checkname() %>
plz help
df
|
|
|
|
|
Your only bet would be to use ajax. Normally you can not call sever side functions from javascript. The javascript is running on the local client not on the web server.
Ben
|
|
|
|
|
Yes, me too looking for the same but hardly found any proper answer. Please provide some ans.
|
|
|
|
|
Hi,
I have created a menucontrol in asp, at the moment you must click on the text to make your selection, i would like to know if there is a way to make it so that when you click anywhere in that menu items panel it will make the selection as havin to click on the text is not very effective,
thank you
gav
|
|
|
|
|
Hi,
I asked this same question sometime ago and the good folks here gave me the answer, so it's only fair to pass it on
The problem with the bog standard Menucontrol is it's based on tables, and so only support clicking on the text. However, there is a relatively easy way to sort this out...
CSS Freindly Control Extender!
Check out this link: http://www.asp.net/cssadapters/[^]
|
|
|
|
|
I have been playing with System.Diagnostics and am able to get the event logs from the pc. Can i get other information like CPU usage and Hard Drive Space?
Also Can I get this for multiple server on my network?
Thanks
|
|
|
|
|
Hi,
Iam using nLog logger tool in my ASP.NET application to log my events and errors.Iam new to NLog and just learning the basics. I want to log events to my database and for my application I have to also log the customerid which i get on my form for every log. How do I go about it ? This is what I have in my config file.
<targets>
<target name="database" type="Database">
<dbProvider>mssql</dbProvider>
<dbHost>HOSTNAME</dbHost>
<dbDatabase>DBNAME</dbDatabase>
<dbUserName>USERID</dbUserName>
<dbPassword>PASSWORD</dbPassword>
<commandText>INSERT INTO LOG(LOG.DATE,LOG.LEVEL,LOG.LOGGER,LOG.MESSAGE) VALUES(@time_stamp,@level,@logger,@message);</commandText>
<parameter name="@time_stamp" layout="${date:format=yyyy-MM-dd HH\:mm\:ss}" />
<parameter name="@level" layout="${level}" />
<parameter name="@logger" layout="${logger}" />
<parameter name="@message" layout="${message}" />
</target>
</targets>
This works just fine. I want to add another column to the Log table called CustomerID, how do i change the config file and how do i use it in my code. Example would be great !! Iam using VB.NET and VS 2005
Thanks
RH
|
|
|
|
|
Please Help!!
I an working on a VB application with a datagrid. In the datagrid, i have create a ButtonColumn with "Delete" Command. I also create OnItemCreated="dgProgram_ItemCreated" for the datagrid. I want to confirm the user before delete a row from datagrid. I also want to pass an Object value of that row to client side (example: "are you sure to delete the row number with that name bluh bluh?"). I don't understand why the javascipt always fired before the ItemCreated (dgProgram_ItemCreated function). That's why i can't get the value to pass to javascript.
Please Help. Thanks in Advance!!!
Sub dgProgram_ItemCreated(ByVal sender As Object, ByVal e As DataGridItemEventArgs)
If e.Item.ItemType = ListItemType.Item OrElse e.Item.ItemType = ListItemType.AlternatingItem Then
Dim lbl As New Label
lbl = CType(e.Item.FindControl("lblProgram"), Label)
//program is a hidden field
Me.program.Value = CType(lbl.Text, String)
Dim btn As Button
btn = CType(e.Item.Cells(14).Controls(0), Button)
btn.Attributes.Add("onclick", "return deleteconfirm(program)")
End If
End Sub
function deleteconfirm(v)
{
return confirm('Are you sure to delete this program: '+ v.value);
}
|
|
|
|
|
You might have better luck putting this in the ItemDataBound event...
Otherwise, you could try looping through the rows after binding the database (in whatver sub you do that) with something like the below, amending the FindControl paramter with the name you have assigned the delete button in your datagrid. You can find you lblProgram value similarly, and amnend the js accordingly.
Dim c As Button
Dim dgItem As DataGridItem, js As String
For Each dgItem In dgProgram.Items
js = "javascript: return confirm('Do you really want to delete this item?');"
c = dgItem.Cells(14).FindControl("btnDel")
c.Attributes.Add("onclick", js)
c = Nothing
Next
Good luck..
Fred
|
|
|
|
|
I've tried both in sub ItemCreated and ItemDataBound but it does not work. Do you know How and Where to put the (Sub ItemCreated) of the datagrid so it only run when you click on the datagrid or the button inside the datagrid???
In my application now, when i debug it, it run over and over and over again that i have no idea why it does that.
Thanks,
Don
|
|
|
|
|
Well it will do - it will run once for every row in your datagrid, as each row is created (or bound to the data) - that's what these events are; that's why theya re called what they are.
What you are trying to do is attach the appropriate javascript to each button, one on each row, so you want it run over and over like that! All you need to do is fugure out the right code to do it.
You are on the right tracks, but it's hard ot know exactly where you;re going wrong... there are lots of examples on the web about how to do the sort of thig you want. Type "datagrid delete confirm" into Google... or try this site:
http://www.datagridgirl.com/[^]
or this
http://www.4guysfromrolla.com/[^]
both have loads of great tutorials and examples....
Fred
|
|
|
|
|
HI
i want to execute some code after focus move from textbox.is there any
event available similier to onblur event for html textbox
for asp:textbox.
And one more thing when the Keypress
event is executed.(this event is of html textbox).which of the event first
occur
---textchanged event
------keypress event
df
|
|
|
|