|
I haven't done any mobile development, but it would appear that multi-line text on buttons is not supported.
|
|
|
|
|
|
|
This is a question for the ASP.NET Forum.
|
|
|
|
|
It would be better to put the code that adds the attribute to the onclick event to the pre-render event of the datagrid. javascript executes on the client so it will always happen before the item creted event. In the prereder event you can loop through the rows in the datagrid and add the attribute to the correct button based off the label on that row.
Hope that helps.
Ben
|
|
|
|
|
could you please provide some sample code? One more thing, I want "onclick" event fired after the button in datagrid clicked, because I want to get the value from that row. But it seem like the client scipt always fired before the item of datagrid created. Please help. I really appreciated.
|
|
|
|
|
First, the javascript will always fire before the post back to the page. That is ok you just have to set the javascript on the first page load of the page. I will give you the basics of what you need to do then I think you should try to do it, if you run into trouble let me know and I can try to help you with your code. It doesn't help you learn much if I just write the code for you.
prerender of the gridview event
foreach gridviewrow in gridview
lbl = gridviewrow.findcontrol 'This is where you get the label or whatever
'that has what info you need
btn = gridviewrow.findcontrol 'this is where you get the delete button
btn.Attributes.add("onclick","return deleteconfirm("+lbl.text+")"))
end forloop
Hope that helps.
Ben
|
|
|
|
|
Hi Ben,
Thanks for your suggestion, but i don't think it's going to work.
Here is what i have:
Sub dgProgram_PreRender(ByVal sender As Object, ByVal e As System.EventArgs)
Dim item As DataGridItem
For Each item In dgProgram.Items
Dim lbl As Label
Dim btn As Button
lbl = CType(item.FindControl("lblProgram"), Label)
Me.program.Value = lbl.Text
btn = CType(item.FindControl("btnDel"), Button)
btn.Attributes.Add("onclick", "return deleteTesting(" + program.ClientID + ");")
'btn.Attributes.Add("onclick", "return deleteTesting(" + lbl.Text + ")")
Next
End Sub
function deleteTesting(v)
{
//v = document.getElementById("<%= program.ClientID %>").value;
return confirm('are you sure to delete ' + v.value + '?');
}
You said the javascript always fire before the postback, then how can we pass the current value of the row that we click on to the javascript. I have tried it many ways, it only pass the value of the last row of the datagrid to javascript. Supposed I have 5 rows in datagrid, when i click "delete" on row 1 and row 3, how we pass the values of these 2 rows to javascipt if you said the javascipt fire before the postback? What am I missing? Please Help!
|
|
|
|
|
What you will want to do is pass in the lbl.ClientID. Then you will have the actual label getting passed into the javascript. So then the v.value should be correct.
Ben
|
|
|
|
|
Ben,
I know that. But what I am talking about is that if you have a datagrid of 5 rows, the label store only one value of the last row in datagrid, because when you loop through the datagrid items in prerender event, the label get only the value of the last row, and the javascript fire before the postback. So no matter which row you click on "delete", it only pass the value of the last row to javascript. You agree? Anyone out there have any idea how to get the value of the row you click on? Thanks
|
|
|
|
|
So you are saying that the label is not in the datagrid row, but out side of the datagrid itself? If that is the case I would suggest adding a template column that has a label that you set to visible = false. Then pass that label in from each datagrid row and you should be good.
Ben
|
|
|
|
|
Normally when you pass the clientID of a control into javascript it is just like passing the object itself. I would suggest debuging the javascript and seeing if the label object is getting passed in. I have a fair bit of code that does some very similar stuff so I know it can be done.
I have written an article on debugging javascript if that helps:
http://www.codeproject.com/useritems/UsingVSToDebugJavascript.asp[^]
Ben
|
|
|
|
|
Ben,
Your article is great
That is cool if i could debug the javascript. I did not know that.
I have tried it: I have set the breakpoint both in pagebehind code and the javacript. But when i debug it, it only run through the pagebehind code. how do i make the pointer go through the javascipt in aspx page where i set the breakpoint? Thanks.
|
|
|
|
|
Make sure your IE browser has unchecked the disable script debugging. Then in your Internet explorer click on view then script debugger and then break next statement. Then when you click the button it should go into the html file. Press F11 to step into the javascript call.
Ben
|
|
|
|
|
Hi all! I saw Damien's replies on the offer to help with some code, but havnt had any luck in contacting him. I reached a bit of a struggling point, and hope someone can be able to help? Im receiving GPS data through the COM port. Only the GPRMC sentence. I have to display the route (or path) a person moved, for example, on a graph of about 20mx20m... If anyone can help me with that code, id really appreciate it, its also for my final project at uni, and unfortunately its my first time with VB.I also have to display a box with total distance travelled, but that wont be to difficult i reckon, its only a simple Pythagoras with the x and y.
Thank all for the time to read this!
|
|
|
|
|
Hey,
I've created a word document and have added text to it. I now need to select this text and pass it to a string variable. Any ideas? Also, if this is possible, if some of the text was bolded...will those properties be passed through to the string variable? Just curious, thanks.
---
reegan41
|
|
|
|
|
reegan41 wrote: I now need to select this text and pass it to a string variable
Sure. You would need the Visual Studio Tools for Office or the Office Primary Interop Assemblies. Then, you would use the Word object model to select and copy the text. Something like this[^] exmaple.
reegan41 wrote: Also, if this is possible, if some of the text was bolded...will those properties be passed through to the string variable?
No. The string variable cannot hold the Word formatting objects. You'll get just the text, nothing more.
|
|
|
|
|
thanks alot man
Cheers,
reegan41
|
|
|
|
|
I have the need to group a set of text boxes and labels for ease of use. I want to put a simple box around these items and I am not sure if a GroupBox is overkill for it.
Any recommendations or is it fine to use a GroupBox for nothing but aesthetics?
Thanks,
Dan
|
|
|
|
|
A GroupBox is a pretty lightweight control. It'll work for what you want it to do. Just don't expect a lot of customization options with it.
|
|
|
|
|
hi,
i create simple png file which draw user specified string. i accept input from user through Text box(here name is txtString).However following code create Png file but size is more(above 1 KB) for simple string which contains few character(here string contains "aaa").
Dim g As Drawing.Graphics = Nothing<br />
Dim bm_width As Integer = 170<br />
Dim bm_height As Integer = 200<br />
<br />
Dim newBitmap As Bitmap = New Bitmap(bm_width, bm_height, Imaging.PixelFormat.Format24bppRgb)<br />
g = Drawing.Graphics.FromImage(newBitmap)<br />
g.PageUnit = GraphicsUnit.Pixel<br />
g.DrawImage(newBitmap, 0, 0, bm_width, bm_height)<br />
<br />
g.FillRectangle(Brushes.White, 0, 0, bm_width, bm_height)<br />
Dim b As Font<br />
Dim a As New FontDialog<br />
If a.ShowDialog = Windows.Forms.DialogResult.OK Then<br />
b = a.Font<br />
End If<br />
<br />
Dim str As String<br />
str = txtString.Text.Trim <br />
g.DrawString(str, b, Brushes.Black, 0, Ypos)<br />
newBitmap.Save("c:\Drawing\" & txtString.Text.Trim & ".png", Imaging.ImageFormat.Png)
how can we reduce size of PNG file.
any help will be appreciated
Rupesh Kumar Swami
Software Engineer,
Integrated Solution,
Bikaner (India)
|
|
|
|
|
PNG is already a compressed format so you're not going to get a smaller size file. Who cares what the text is. On a pixel-by-pixel basis, the more complex the image is, the less "compressible" the image is going to be and the bigger the resulting file.
|
|
|
|
|
I agree. I've noticed his code has a fixed bitmap size and have wondered if he should set the bitmap depending on the text size (unless he's forced with a 170x200 image)...
"Any sort of work in VB6 is bound to provide several WTF moments." - Christian Graus
|
|
|
|
|
Hi all,
A problem takes me back once again to the code project.
Right now I'm working on a small project in which I would like to generate my buttons, textfields etc dynamicly (I have an xml file and when it encouters < control type= button name = btn1/> it creates a button called btn1 and its added to the page (its possible to set the size etc.)
The reason why I'm doing this is that from time to time you just want to add a simple button but don't feel like recompiling the whole project or a client wants an extra button/image and would like to add it himself.... (with some sort of wizard typed thing)
this is all working. buttons and controls are created without a problem. I can retrieve info from my textboxes etc no problem. But well lets say I want to create a button but it needs a new "function" while clicking on it so I would need to add a handler to the button but I don't know what the code is going to be so I added in my xml file: <control type= button name = btn1 handler= btn1_handler/>
This function is then coded in an external file (simple notepad for exemple)
now where I dont really know how to do it is associate this function btn1_handler with my btn1 so that it handles an onclick event... the whole thing without recompiling but using for example vbscript or ICodeCompiler.....
Would this be possible to do? or? because well I dont know what will be in the function nor which button it corresponds to except in my xml file....
any help would be greatly appreciated
Cheers
jozef
its our widgets that make us men
|
|
|
|
|
It's possible. I don't exactly know how, but it is.
I'm figuring that you would have to load the button handler text into a CodeDom and compiler it into an in-memory assembly. This assembly would then have to be loaded into the AppDomain, kind of like plugin functionality. You'd then have to wire up the event handler yourself after the code is loaded.
Don't ask for example on this one for I don't have any. This is all just speculation. I've given you enough keywords to Google on to get the smaller parts of the problem solved though. After that, it's a matter of stringing those smaller solutions together to get this to work.
|
|
|
|