Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Function calling from client side

Function calling from client side

Scheduled Pinned Locked Moved ASP.NET
helpquestionhtmlcssdocker
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gekoscan
    wrote on last edited by
    #1

    Hey... I have data bound to a DataList and I can access any column of it by going <%# DataBinder.Eval(Container.DataItem, "Description")%> in the html code. My problem is the data is to long and I want to trim it to 40 characters or less. So I wrote a function to do so. public void Description() { string sDescription = string sTemp = string.Empty; for (int i=0;i<40;i++) sTemp += sDescription[i]; sTemp += "..."; Response.Write(sTemp); } now how do I pass in the description string????? you can't use <% %> inside a scripted function???? Can anyone help me or if anyone has a better way of doing this I would love to hear it!! Thanks, Steve Nelson

    P 1 Reply Last reply
    0
    • G gekoscan

      Hey... I have data bound to a DataList and I can access any column of it by going <%# DataBinder.Eval(Container.DataItem, "Description")%> in the html code. My problem is the data is to long and I want to trim it to 40 characters or less. So I wrote a function to do so. public void Description() { string sDescription = string sTemp = string.Empty; for (int i=0;i<40;i++) sTemp += sDescription[i]; sTemp += "..."; Response.Write(sTemp); } now how do I pass in the description string????? you can't use <% %> inside a scripted function???? Can anyone help me or if anyone has a better way of doing this I would love to hear it!! Thanks, Steve Nelson

      P Offline
      P Offline
      Paul Riley
      wrote on last edited by
      #2

      You could probably use <%= myField %>, but it's probably better to use Data Formatting in the DataBind. ie. <%# DataBinder.Eval(Container.DataItem, "Description")%> becomes <%# DataBinder.Eval(Container.DataItem, "Description", "{0,40}")%> (I think I have that right, I'm working from memory, but it should lead you in the right direction if it's not quite there) Paul We all will feed the worms and trees
      So don't be shy
      - Queens of the Stone Age, Mosquito Song

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups